Skip to content

Enable errorlint for error comparisons and type assertions - #7084

Merged
denik merged 2 commits into
mainfrom
denik/errorlint
Oct 16, 2026
Merged

denik merged 2 commits into
mainfrom
denik/errorlint

Conversation

@denik

@denik denik commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Changes

Enable errorlint with only its comparison and type-assertion checks, and fix its 29 findings: err == ErrX becomes errors.Is(err, ErrX) and err.(*T) becomes errors.AsType[*T](err). The errorf check (%v → %w in fmt.Errorf) stays off: wrapping makes the cause visible to every errors.Is/errors.As up the stack (e.g. fs.ErrNotExist, context.Canceled), so converting its 36 sites is a behavior change that needs per-site review in a separate PR.

Why

These checks break silently as soon as the error is wrapped with %w. No current site is broken, since every sentinel is still returned unwrapped, but the codebase was inconsistent: for example cmd/bundle/validate.go compared root.ErrAlreadyPrinted with != while cmd/bundle/utils/process.go uses errors.Is.

Tests

golangci-lint reports 0 issues on the root and tools modules. Unit tests pass for every changed package, and the cmd/ and bundle/validate/ acceptance tests pass. One test keeps its != with a //nolint:errorlint, because it checks that mapUploadError returns the same error rather than a wrapper.

This pull request and its description were written by Isaac.

Compare errors with errors.Is and unwrap them with errors.AsType, so the
checks keep working if the error is wrapped later. errorf is disabled:
formatting errors with %v is often deliberate.

Co-authored-by: Isaac <no-reply@databricks.com>
@github-actions github-actions Bot added DABs DABs related issues PyDABs AIR Databricks AI Runtime CLI labels Oct 16, 2026
Co-authored-by: Isaac <no-reply@databricks.com>
@denik
denik marked this pull request as ready for review October 16, 2026 08:46
@denik
denik requested review from a team as code owners October 16, 2026 08:46
@denik
denik enabled auto-merge October 16, 2026 08:46
@eng-dev-ecosystem-bot

Copy link
Copy Markdown
Collaborator

Integration test report

Commit: 753f11d

Run: 38875982079

Env 🔄​flaky ✅​pass 🙈​skip Time
✅​ aws linux-2core-8gb 276 15 5:24
✅​ aws-windows-latest-4core-16gb 278 13 5:08
✅​ azure linux-2core-8gb 275 15 5:23
🔄​ azure-windows-latest-4core-16gb 1 276 13 7:09
✅​ gcp linux-2core-8gb 276 15 5:26
✅​ gcp-windows-latest-4core-16gb 278 13 5:20
Test Name azure-windows-latest-4core-16gb
🔄​ TestAccept 🔄​f
Top 6 slowest tests (at least 2 minutes):
duration env testname
5:13 gcp-windows-latest-4core-16gb TestAccept
5:00 aws-windows-latest-4core-16gb TestAccept
3:48 aws linux-2core-8gb TestAccept
3:47 gcp linux-2core-8gb TestAccept
3:46 azure linux-2core-8gb TestAccept
2:50 azure-windows-latest-4core-16gb TestAccept

@denik
denik added this pull request to the merge queue Oct 16, 2026
Merged via the queue into main with commit 45ff522 Oct 16, 2026
44 of 46 checks passed
@denik
denik deleted the denik/errorlint branch October 16, 2026 09:31
arushiagarwal-db pushed a commit to arushiagarwal-db/cli that referenced this pull request Oct 19, 2026
…s#7090)

## 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 databricks#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.

Co-authored-by: Isaac <no-reply@databricks.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AIR Databricks AI Runtime CLI DABs DABs related issues PyDABs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants