Skip to content

Return errors instead of accumulating diagnostics#5721

Draft
denik wants to merge 6 commits into
mainfrom
denik/idiomatic-err-return
Draft

Return errors instead of accumulating diagnostics#5721
denik wants to merge 6 commits into
mainfrom
denik/idiomatic-err-return

Conversation

@denik

@denik denik commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Replace the logdiag-based diagnostics accumulation in the bundle pipeline with idiomatic Go error returns.

  • Mutators, phases, deploy, statemgmt and the direct engine return error; logdiag.LogError and logdiag.HasError are removed.
  • diag.Diagnostic implements error. Errors render via logdiag.FlushError at their source (idempotent), so the user sees them before slow deferred cleanup. Mutators that report multiple errors log each via logdiag.Flush(ctx, diags) (or return diags.Error() from parallel validators).
  • Warnings and recommendations are still emitted immediately via logdiag.LogDiag.

The only acceptance output changes are the redundant generic "planning failed" wrapper being dropped (the specific resource errors are still shown) and multi-error blocks now rendering as separate Error: entries.

This pull request and its description were written by Isaac.

denik added 5 commits June 25, 2026 11:20
Replace the logdiag-based error accumulation in the bundle pipeline with
idiomatic Go error returns. Mutators, phases, deploy, statemgmt and the
direct engine now return error; logdiag.LogError and logdiag.HasError are
removed.

A diag.Diagnostic implements error and diag.Diagnostics.Error() combines all
error-severity diagnostics (via errors.Join) so a returned error still unpacks
into separate diagnostic blocks and reports the error count when rendered.
logdiag.FlushError renders errors at their source (before slow deferred
cleanup) and is idempotent, with RenderAndReturnError as the boundary fallback.

Co-authored-by: Isaac
Mutators that report several errors now log each diagnostic immediately and
return the ErrAlreadyPrinted sentinel, via the new logdiag.Flush(ctx, diags)
helper, instead of combining them into an errors.Join. This keeps errors
adjacent to their warnings in source order and lets the error count fall out of
the logdiag counter.

Test helpers skip appending the returned error when it is ErrAlreadyPrinted
(those diagnostics are already collected). logdiag tracks the first error
summary again so deploy telemetry stays meaningful when the returned error is
the opaque sentinel.

Co-authored-by: Isaac
ValidateDeploymentFields (added on main) now returns error via logdiag.Flush.
Update the IsolatedContext test and ValidateDeploymentFields test to the new
API (run the mutator via bundle.Apply / assert the returned error). The
yaml-sync config-snapshot warning now carries the specific failure instead of a
generic "state conversion failed" wrapper.

Co-authored-by: Isaac
Audit every mutator that reported multiple errors before the refactor and
restore that behavior where it had regressed to first-error-only. Sequential
mutators accumulate diagnostics and return logdiag.Flush(ctx, diags) (log each,
return ErrAlreadyPrinted); the read-only parallel validators return
diags.Error() so ApplyParallel joins them deterministically.

run_as and validate_target_mode already preserved all errors via
diag.Diagnostics.Error() (errors.Join); apply_presets and set_variables only
ever produced a single error and are unchanged.

Co-authored-by: Isaac
@denik denik temporarily deployed to test-trigger-is June 25, 2026 12:06 — with GitHub Actions Inactive
@denik denik temporarily deployed to test-trigger-is June 25, 2026 12:06 — with GitHub Actions Inactive
@github-actions

github-actions Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Approval status: pending

/acceptance/bundle/ - needs approval

7 files changed
Suggested: @pietern
Also eligible: @janniklasrose, @shreyas-goenka, @andrewnester, @lennartkats-db, @anton-107

/bundle/ - needs approval

179 files changed
Suggested: @pietern
Also eligible: @janniklasrose, @shreyas-goenka, @andrewnester, @lennartkats-db, @anton-107

/cmd/apps/ - needs approval

Files: cmd/apps/deploy_bundle.go, cmd/apps/dev.go, cmd/apps/import.go
Suggested: @MarioCadenas
Also eligible: @fjakobs, @atilafassina, @Shridhad, @keugenek, @igrekun, @pkosiec, @pffigueiredo, @ditadi, @calvarjorge

/cmd/bundle/ - needs approval

20 files changed
Suggested: @pietern
Also eligible: @janniklasrose, @shreyas-goenka, @andrewnester, @lennartkats-db, @anton-107

/cmd/labs/ - needs approval

Files: cmd/labs/project/entrypoint.go
Eligible: @alexott, @asnare

/cmd/pipelines/ - needs approval

5 files changed
Suggested: @lennartkats-db
Also eligible: @kanterov, @jefferycheng1

/cmd/root/ - needs approval

5 files changed
Suggested: @simonfaltum
Also eligible: @Divyansh-db, @mihaimitrea-db, @tanmay-db, @renaudhartert-db, @hectorcast-db, @parthban-db, @tejaskochar-db, @chrisst, @rauchy

/libs/template/ - needs approval

Files: libs/template/renderer_test.go
Suggested: @pietern
Also eligible: @janniklasrose, @shreyas-goenka, @andrewnester, @lennartkats-db, @anton-107

General files (require maintainer)

6 files changed
Based on git history:

  • @pietern -- recent work in bundle/config/mutator/, bundle/config/mutator/resourcemutator/, bundle/config/validate/

Any maintainer (@andrewnester, @anton-107, @pietern, @shreyas-goenka, @simonfaltum, @renaudhartert-db) can approve all areas.
See OWNERS for ownership rules.

@eng-dev-ecosystem-bot

eng-dev-ecosystem-bot commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

Integration test report

Commit: 015c702

Run: 28172650100

Env 🟨​KNOWN 🔄​flaky 💚​RECOVERED 🙈​SKIP ✅​pass 🙈​skip Time
🟨​ aws linux 7 1 13 240 1026 5:33
🔄​ aws windows 4 4 13 242 1024 10:01
💚​ aws-ucws linux 8 13 327 943 5:18
💚​ aws-ucws windows 8 13 329 941 5:56
💚​ azure linux 2 15 243 1024 4:29
💚​ azure windows 2 15 245 1022 6:01
💚​ azure-ucws linux 2 15 332 939 5:18
💚​ azure-ucws windows 2 15 334 937 5:18
💚​ gcp linux 2 15 242 1026 4:09
💚​ gcp windows 2 15 244 1024 4:53
21 interesting tests: 13 SKIP, 7 KNOWN, 1 RECOVERED
Test Name aws linux aws windows aws-ucws linux aws-ucws windows azure linux azure windows azure-ucws linux azure-ucws windows gcp linux gcp windows
🟨​ TestAccept 🟨​K 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R
🙈​ TestAccept/bundle/invariant/no_drift 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/permissions 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🟨​ TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/with_permissions 🟨​K 💚​R 💚​R 💚​R 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🟨​ TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/with_permissions/DATABRICKS_BUNDLE_ENGINE=direct 🟨​K 🔄​f 💚​R 💚​R
🟨​ TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/with_permissions/DATABRICKS_BUNDLE_ENGINE=terraform 🟨​K 🔄​f 💚​R 💚​R
🟨​ TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/without_permissions 🟨​K 💚​R 💚​R 💚​R 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🟨​ TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/without_permissions/DATABRICKS_BUNDLE_ENGINE=direct 🟨​K 🔄​f 💚​R 💚​R
🟨​ TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/without_permissions/DATABRICKS_BUNDLE_ENGINE=terraform 🟨​K 🔄​f 💚​R 💚​R
🙈​ TestAccept/bundle/resources/postgres_branches/basic 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/postgres_branches/recreate 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/postgres_branches/replace_existing 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/postgres_branches/update_protected 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/postgres_branches/without_branch_id 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/postgres_endpoints/basic 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/postgres_projects/update_display_name 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/synced_database_tables/basic 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/vector_search_endpoints/drift/recreated_same_name 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/vector_search_indexes/recreate/embedding_dimension 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/ssh/connection 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
💚​ TestFetchRepositoryInfoAPI_FromRepo 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R
Top 4 slowest tests (at least 2 minutes):
duration env testname
4:22 azure windows TestAccept
3:33 gcp windows TestAccept
3:21 azure-ucws windows TestAccept
3:20 aws-ucws windows TestAccept

Full golangci-lint (errcheck) flagged callers of ApplyFuncContext and the
phases.* functions in benchmark/test helpers that ignored the now-returned
error. Check them (require.NoError, or _ = in benchmark loops).

Co-authored-by: Isaac
@denik denik temporarily deployed to test-trigger-is June 25, 2026 13:12 — with GitHub Actions Inactive
@denik denik temporarily deployed to test-trigger-is June 25, 2026 13:12 — with GitHub Actions Inactive
@denik denik marked this pull request as draft June 25, 2026 13:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants