Skip to content

Enable errorlint errorf and wrap errors with %w where safe - #7090

Open
denik wants to merge 1 commit into
mainfrom
denik/errorlint-errorf
Open

denik wants to merge 1 commit into
mainfrom
denik/errorlint-errorf

Conversation

@denik

@denik denik commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Changes

Turn on errorlint's errorf check and switch 29 fmt.Errorf calls from %v/%s to %w. Seven calls keep %v with a //nolint:errorlint reason, because wrapping would change behavior:

  • bundle/config/mutator/set_variables.go (4): setVariable runs inside dyn.Map, which returns the original value with no error when the callback fails with a no-such-key or cannot-traverse-nil error. A wrapped dyn.Get(v, "default") failure would leave the variable unset without any error.
  • libs/sync/snapshot.go snapshot write: bundle/deploy/files/upload.go reports fs.ErrPermission from RunOnce as missing workspace permissions, but this is a local file.
  • libs/aitools/installer/installer.go (2): a secondary failure next to the primary %w.

Why

Follow-up to #7084, which left errorf off pending per-site review. For each converted site I checked the error's path up to the command for errors.Is/errors.As that could now match the cause. The global handlers only inspect root.ErrAlreadyPrinted and *apierr.APIError (in diag.FromErr), and none of these causes can contain an API error.

Tests

The error text is identical under %v and %w, so no golden files change. golangci-lint reports 0 issues on the root and tools modules; unit tests pass for all changed packages; acceptance tests under bundle/variables, bundle/artifacts, bundle/python and bundle/destroy pass.

This pull request and its description were written by Isaac.

Enable errorlint's errorf check. Convert the fmt.Errorf calls whose wrapped
cause cannot be matched by any errors.Is/As on the path up to the command.

Keep %v, with a nolint reason, where wrapping would change behavior:
- set_variables runs inside dyn.Map, which returns no error when the callback
  error is a no-such-key/cannot-traverse-nil error, so wrapping would silently
  leave the variable unset.
- The sync snapshot write: files.Upload reports fs.ErrPermission as missing
  workspace permissions, but this error comes from a local file.
- The two installer errors that carry a secondary failure next to %w.

Co-authored-by: Isaac <no-reply@databricks.com>
@github-actions github-actions Bot added DABs DABs related issues PyDABs labels Oct 16, 2026
@eng-dev-ecosystem-bot

Copy link
Copy Markdown
Collaborator

Integration test report

Commit: 8d84b3f

Run: 38881320791

Env 🔄​flaky ✅​pass 🙈​skip Time
✅​ aws linux-2core-8gb 276 15 5:18
✅​ aws-windows-latest-4core-16gb 278 13 5:23
✅​ azure linux-2core-8gb 275 15 5:22
🔄​ azure-windows-latest-4core-16gb 1 276 13 8:29
✅​ gcp linux-2core-8gb 276 15 5:23
✅​ gcp-windows-latest-4core-16gb 278 13 5:32
Test Name azure-windows-latest-4core-16gb
🔄​ TestAccept 🔄​f
Top 6 slowest tests (at least 2 minutes):
duration env testname
5:24 gcp-windows-latest-4core-16gb TestAccept
5:16 aws-windows-latest-4core-16gb TestAccept
3:46 gcp linux-2core-8gb TestAccept
3:42 aws linux-2core-8gb TestAccept
3:42 azure linux-2core-8gb TestAccept
3:25 azure-windows-latest-4core-16gb TestAccept

@denik
denik marked this pull request as ready for review October 16, 2026 10:52
@denik
denik requested review from a team and lennartkats-db as code owners October 16, 2026 10:52
Comment thread libs/sync/snapshot.go
return fmt.Errorf("failed to json marshal in-memory snapshot: %w", err)
}
if err := atomicfile.Write(s.snapshotPath, bytes, 0o644); err != nil {
return fmt.Errorf("failed to write sync snapshot to disk: %s", err)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why now use %w here?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

DABs DABs related issues PyDABs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants