Repository navigation
[AIR] CNXT-2683: Emit air run config-validation errors as JSON with -o json - #7864
Conversation
`databricks air run -o json` printed config-validation failures (local schema errors such as "max_retries must be >= 0" and backend field errors from --dry-run) as plain text, so scripts parsing the JSON envelope broke. Route both through the existing error envelope (INVALID_ARGS / PERMANENT), matching the other air commands. Co-authored-by: Isaac <no-reply@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
|
Commit: Regression test reportSelected 6 changed tests (limit=20, 0 not selected) 6 tests: regression=6 unreleased=0 coverage=0 failing=0
TestAccept/air/run: branch ✅ | main (8b7f43f) ❌ | latest (v1.27.0) ❌main (8b7f43f): latest (v1.27.0): TestAccept/air/run-backend-error: branch ✅ | main (8b7f43f) ❌ | latest (v1.27.0) ❌main (8b7f43f): latest (v1.27.0): same output as main (8b7f43f) TestAccept/air/run-rejected-credentials/me-401: branch ✅ | main (8b7f43f) ❌ | latest (v1.27.0) ❌main (8b7f43f): latest (v1.27.0): same output as main (8b7f43f) TestAccept/air/run-rejected-credentials/me-403: branch ✅ | main (8b7f43f) ❌ | latest (v1.27.0) ❌main (8b7f43f): latest (v1.27.0): same output as main (8b7f43f) TestAccept/air/run-rejected-credentials/validate-401: branch ✅ | main (8b7f43f) ❌ | latest (v1.27.0) ❌main (8b7f43f): latest (v1.27.0): same output as main (8b7f43f) TestAccept/air/run-rejected-credentials/validate-403: branch ✅ | main (8b7f43f) ❌ | latest (v1.27.0) ❌main (8b7f43f): latest (v1.27.0): same output as main (8b7f43f) |
There was a problem hiding this comment.
Automated review at bed61e9. Each finding was verified against the code.
Not ready yet: 1 blocking issue(s), tagged [blocking]; part of the automated review did not complete.
This PR wraps two air run error paths (loadRunConfigWithOverrides and backend-validation errors) with renderError so they emit JSON envelopes under -o json. The fix is correct for those two sites, but the same RunE function has additional bare return err paths—inside the dryRun block it already modifies—that still emit plain text in JSON mode. The new acceptance test also uses errcode where the testing rules require musterr.
Comments outside the changed lines
- [blocking]
cmd/air/run.go:178:countSnapshotFiles(line 178) andvalidateIdempotencyToken(line 185) are inside the samedryRunblock where lines 165 and 190 now callrenderError, but these two still do a barereturn err. With--dry-run -o jsonand a config that hascode_source.snapshotpointing at a missing directory, or an invalid idempotency token, the CLI prints plainError: …instead of a JSON envelope—the exact class of bug this PR fixes elsewhere.submitWorkloadat line 221 has the same gap on the non-dry-run path. Wrap all three inrenderError(it already no-ops in text mode), or add a single fallback wrapper at theRunEboundary so future error paths are covered automatically.
…ON test Review round 1: code_source snapshot resolution and the idempotency-token check in the --dry-run block also returned plain text under -o json. Route them through renderError too, and assert the expected failure with musterr. Co-authored-by: Isaac <no-reply@databricks.com>
|
/review |
There was a problem hiding this comment.
Automated review at 71adc65. Each finding was verified against the code.
Not ready yet: 1 blocking issue(s), tagged [blocking].
This PR makes air run -o json emit config-validation failures as structured JSON error envelopes instead of plain text, matching the other air commands. The change wraps four error-return sites in renderError calls. One of these sites can receive authentication errors that get mislabeled; otherwise the approach is consistent with the existing air get pattern.
Review round 2: a failed workspace-client setup during --dry-run was labeled INVALID_ARGS. Mark it as an authentication error and route it through authError, like the other air commands. Co-authored-by: Isaac <no-reply@databricks.com>
|
/review |
✅ Integration test reportCommit: f227b4e
Top 44 slowest tests (at least 2 minutes):
|
|
/review |
1 similar comment
|
/review |
…AUTHENTICATED Review feedback (caroline-db): credentials can still be rejected after the workspace client is built, by CurrentUser.Me in prospectiveLaunchPaths or by config:validate. Those errors fell through as INVALID_ARGS, which tells an agent to edit a valid config. Route errors that wrap apierr.ErrUnauthenticated or apierr.ErrPermissionDenied through authError, and cover both endpoints with 401 and 403. Co-authored-by: Isaac <no-reply@databricks.com>
|
/review |
There was a problem hiding this comment.
Automated review at 6236c7e. Each finding was verified against the code.
Not ready yet: 2 blocking issue(s), tagged [blocking].
This PR routes air run config-validation failures through renderError, so -o json gets the INVALID_ARGS envelope, and sends dry-run credential failures to authError. The local-validation paths look right. The new auth classification has two problems that should be fixed before merge. First, the bundle-diagnostics sentinel gets a second, retryable envelope. Second, a 403 from config:validate is reported as bad credentials even after the current-user lookup has just succeeded with the same credentials. Text-mode output also changes on the auth branch, although the description says text mode is unaffected.
Review round 3: - MustWorkspaceClient returns root.ErrAlreadyPrinted after bundle diagnostics; pass it through instead of adding a second, retryable INTERNAL_ERROR envelope. - A 403 from the current-user lookup or config:validate means the credentials work but lack access: report PERMISSION_DENIED, and keep UNAUTHENTICATED for 401s and clients that can't be built. - Apply the authError rewrite only with -o json, so text mode keeps the original error. Co-authored-by: Isaac <no-reply@databricks.com>
|
/review |
There was a problem hiding this comment.
Automated review at 5e3b435. Each finding was verified against the code.
No blocking issues found. 4 non-blocking comment(s) below.
This PR makes air run -o json wrap local config-validation, snapshot, idempotency-token and dry-run backend errors in the standard JSON error envelope. It also gives dry-run credential failures their own codes. The core change, routing local validation errors through renderError as INVALID_ARGS, looks right. The new credential classification has two problems. A client that can't be built can still come back as a retryable INTERNAL_ERROR. And a 403 is reported differently from every other air command. One new acceptance fixture also goes against the testing rules.
Comments outside the changed lines
- [nice to have]
acceptance/air/run/script:142: The brokendatabricks.ymlis a static input, but the script builds it withmkdir/printfand deletes it afterwards. That goes against the testing rule "Commit static test inputs into the test directory instead of creating them inscript". Can you commitacceptance/air/run/broken-bundle/databricks.ymland run the command withwithdir broken-bundle ...instead? - [nit]
.nextchanges/air/run-json-validation-errors.md:7: The entry only mentions config-validation errors. With-o json,--dry-runcredential failures now also come back asUNAUTHENTICATEDenvelopes, and 403s get a newPERMISSION_DENIEDcode. Scripts that match onerror.codewill see both, so can the entry mention them?
… fixture Review round 4 nits: - The current-user lookup fails only for bad credentials, so a 403 from it now goes through authError (UNAUTHENTICATED), as in air get. A 403 from config:validate after that lookup passed stays PERMISSION_DENIED. - Say in the comment that workspace-client failures go through authError. - Commit the broken databricks.yml fixture and run it with withdir. - Mention the new dry-run auth codes in the changelog fragment. Co-authored-by: Isaac <no-reply@databricks.com>
|
/review |
There was a problem hiding this comment.
Automated review at b27955b. Each finding was verified against the code.
No blocking issues found. 1 non-blocking comment(s) below.
This PR makes air run -o json print config-validation failures as the standard JSON error envelope. It also keeps credential and permission failures during --dry-run separate from config errors. The local-validation paths look right. One problem: every workspace-client setup failure now goes through authError, so a permanent local misconfiguration is reported as a retryable transient error.
The fixture was a YAML syntax error, which fmt-yaml rejects. Mark two targets as default instead (as acceptance/cmd/feedback does): the file is valid YAML but an invalid bundle, so air run still sees printed diagnostics. Co-authored-by: Isaac <no-reply@databricks.com>
|
/review |
There was a problem hiding this comment.
Automated review at 331aebe. Each finding was verified against the code.
No blocking issues found. 1 non-blocking comment(s) and 2 question(s) below.
This PR makes air run -o json report config-validation failures (local schema and overrides, snapshot resolution, idempotency token, backend field errors from --dry-run) as JSON error envelopes. It also separates credential and permission failures during --dry-run from config errors. The main paths look right and are covered by acceptance and unit tests. One real problem remains: deterministic client-setup failures on the dry-run path are now reported as retryable.
Questions
- Without
--dry-run,PreRunE(run.go:185) still returnsMustWorkspaceClienterrors unchanged. Soair run -f x.yaml -o jsonwith missing credentials printsError: default auth: ...as text, while the same command with--dry-runnow prints anUNAUTHENTICATEDenvelope.air get'sPreRunE(get.go:196-202) already passesErrAlreadyPrintedthrough and sends other failures toauthError. Shouldair run'sPreRunEdo the same so both modes agree, or is that left for a follow-up? (non-blocking) - When bundle loading fails (the "bundle diagnostics are reported once (json)" case),
-o jsonprints the diagnostics as text and returnsErrAlreadyPrinted, leaving stdout empty. A JSON consumer gets a non-zero exit and nothing to parse. Is matchingair getthe intended behavior here, or should this path also print an envelope (for exampleINVALID_ARGSpointing at the bundle)? (non-blocking)
…ir run Review of 331aebe (addressed in code per Vincent): - A workspace-client setup failure that isn't an auth error (an unknown or account-only profile) is INVALID_ARGS/PERMANENT, not authError's retryable INTERNAL_ERROR fallback. Scoped to air run. - The non-dry-run PreRunE renders the same envelopes as --dry-run, as air get's PreRunE does. - Bundle diagnostics that were already printed still pass through without an envelope, matching air get; covered in both modes. - Normalize the bundle loader's random default-target order in the test. Co-authored-by: Isaac <no-reply@databricks.com>
|
/review |
There was a problem hiding this comment.
Automated review at e937cbe. Each finding was verified against the code.
Not ready yet: 1 blocking issue(s), tagged [blocking].
This PR makes air run -o json report config-validation, workspace-client and dry-run credential failures as JSON error envelopes, and adds acceptance cases and a unit test for them. The envelope routing mostly holds up. One problem remains: the new early return on ErrAlreadyPrinted in the dry-run path skips the idempotency-token check, so text and JSON modes report different errors for the same input, and text mode loses an error it used to print. The 401/403 envelope cases also live only in a unit test, not in the acceptance goldens.
Comments outside the changed lines
- [nice to have]
cmd/air/run_test.go:359:.agents/rules/testing.mdsays user-visible CLI output should be tested with acceptance tests first. This test only asserts the JSON envelope printed for a 401/403 from/scim/v2/Meandconfig:validate, including the newPERMISSION_DENIEDcode, so the exact envelope text never lands in a golden file. Could these be acceptance cases next toacceptance/air/run-backend-error, which already stubsconfig:validatewith[[Server]], usingResponse.StatusCode = 401/403and anerror_codebody undermusterr trace ... --dry-run -o json?
Review of e937cbe: - [blocking] Rendering the workspace-client error inside the dry-run validation skipped the idempotency-key check, so -o json hid an over-long key behind UNAUTHENTICATED and text mode dropped the key error after bundle diagnostics. Return the raw error and render it after the key check, restoring the original order in both modes. - Add an acceptance golden for the PERMISSION_DENIED envelope from a config:validate 403. Co-authored-by: Isaac <no-reply@databricks.com>
|
/review |
There was a problem hiding this comment.
Automated review at 2c60ba9. Each finding was verified against the code.
Not ready yet: 1 blocking issue(s), tagged [blocking].
With -o json, this PR sends air run's config-validation, workspace-client and --dry-run caller errors through the shared JSON error envelope, and keeps credential and permission failures separate from INVALID_ARGS. The local-validation wrapping looks right. One problem: the catch-all INVALID_ARGS fallback in renderWorkspaceClientError also catches expired-login and network failures from Authenticate, which is the misclassification the PR is meant to prevent. There is also a small overlap between the new unit test and the new acceptance test.
Comments outside the changed lines
- [nit]
cmd/air/run_test.go:467: Theconfig validate/403row checks the same thing asacceptance/air/run-permission-denied: a 403PERMISSION_DENIEDfromconfig:validateunder--dry-run -o json, expected asPERMISSION_DENIED/PERMANENT/non-retryable..agents/rules/testing.mdasks not to add unit tests that only duplicate acceptance coverage. Can we drop this row, or move the other current-user and 401 cases into acceptance tests too?
Review of 2c60ba9: - [blocking] The INVALID_ARGS fallback for workspace-client setup errors also caught failures from authenticating. An expired OAuth login (u2m.InvalidRefreshTokenError) is now UNAUTHENTICATED, and a failure that may pass on retry (network, timeout, 429, 5xx, as classifyValidationFailure reports it) goes through authError's transient fallback. Other setup errors stay INVALID_ARGS/PERMANENT. - [nit] Drop the config:validate 403 unit-test row that duplicates acceptance/air/run-permission-denied. Co-authored-by: Isaac <no-reply@databricks.com>
|
/review |
There was a problem hiding this comment.
Automated review at f73e331. Each finding was verified against the code.
No blocking issues found. 3 non-blocking comment(s) and 2 question(s) below.
This PR makes air run -o json report config-validation, workspace-client and dry-run credential failures as JSON error envelopes instead of plain text, with new acceptance and unit coverage. The local-validation paths look right and the ordering of the idempotency check is kept. What's left is small: three credential cases are only tested in a unit test, not in acceptance goldens; one doc comment overstates which current-user failures go through authError; and a fixture is misleadingly named. There are also two open questions about how the new codes line up with air get and the existing envelope vocabulary.
Questions
renderWorkspaceClientErrorreports an unknown or account-only profile asINVALID_ARGS/PERMANENT, whileair get -p does-not-exist -o jsonstill goes throughauthError's fallback and reportsINTERNAL_ERROR/TRANSIENT/retryable: true(get.go:149-150). So the same setup failure gets different codes from differentaircommands. Should this classification move intoauthError(or a shared helperair get'sPreRunEalso uses) so every command agrees, or stay scoped toair runwith a follow-up forget? (non-blocking)PERMISSION_DENIEDis a new envelope code that no otheraircommand emits.air getreports an API 403 asUNAUTHENTICATED, andoutput.gosays codes, kinds and retryable flags match the PythonairCLI. Should the new code be added here (and documented for agents that branch oncode, including the Python CLI and the skill text), or should aconfig:validate403 reuse an existing code and leave the new one to its own change? (non-blocking)
Review of f73e331 (non-blocking, fixed in code per Vincent): - Cover the current-user 401/403 and config:validate 401/403 envelopes in acceptance/air/run-rejected-credentials, with a config that is actually valid, and drop the unit test that duplicated them. - Say in the doc comment that only a 401 or 403 from the current-user lookup goes through authError. Co-authored-by: Isaac <no-reply@databricks.com>
|
/review |
There was a problem hiding this comment.
Automated review at 9fe1a88. Each finding was verified against the code.
No blocking issues found. 2 non-blocking comment(s) below.
This PR sends air run -o json config-validation failures (local schema, code_source snapshot, idempotency-token length, config:validate field errors) through the JSON error envelope, and classifies workspace-client and credential failures separately. The routing traces correctly and the acceptance goldens match the code. What's left is small: one test case is titled as a JSON case but runs in text mode, and the doc comment on workspaceClientError describes the wrong job for that type.
Comments outside the changed lines
- [nice to have]
acceptance/air/run/script:442: This line sits under the "bundle diagnostics are reported once (json)" title, but it has no-o json. The golden therefore records text mode: the bundle diagnostic, then a secondError: idempotency token .... With-o json,validateIdempotencyTokenruns before theworkspaceClientErrorbranch, so stderr should get the diagnostics and stdout anINVALID_ARGSenvelope, and nothing pins that. Can you add-o jsonhere, or retitle the case if text mode was the intent?
…omment Review of 9fe1a88 (non-blocking): - The text-mode bundle + over-long key case sat under a "(json)" title. Give it its own title and add the -o json variant, which prints the diagnostics and then an INVALID_ARGS envelope for the key. - Describe workspaceClientError as routing the error to renderWorkspaceClientError, not as deciding the order. Co-authored-by: Isaac <no-reply@databricks.com>
|
/review |
There was a problem hiding this comment.
Automated review at 7e074c7. Each finding was verified against the code.
No blocking issues found. 1 non-blocking comment(s) and 1 question(s) below.
This PR makes air run -o json report local config-validation, snapshot, idempotency-key and --dry-run backend errors as JSON error envelopes instead of Error: ... text. It also splits workspace-client, credential and permission failures from config errors. The error paths I traced behave as the description and acceptance goldens say. One thing to fix: the changelog entry promises more for rejected credentials than the non-dry-run path delivers. There is also an open question about keeping a run-only classifier next to authError.
Questions
renderWorkspaceClientError(cmd/air/run.go:101) re-checks the conditionsauthError(cmd/air/get.go:141) already checks, then adds an expired-login case and anINVALID_ARGSfallback that onlyair runuses. As a result,air run -p does-not-exist -o jsonreportsINVALID_ARGS/retryable:false, whileair get 1 -p does-not-exist -o jsonstill reportsINTERNAL_ERROR/retryable:true. TheworkspaceClientErrorandvalidationAuthenticationErrorwrappers exist only to route errors back into this logic. Should these cases go intoauthErrorin this PR so allaircommands share one mapping, or is the planned follow-up close enough that the gap is acceptable? (non-blocking)
Review of 7e074c7 (non-blocking): without --dry-run, a PAT is only checked when the run is submitted, so rejected credentials are reported as UNAUTHENTICATED only during --dry-run. Co-authored-by: Isaac <no-reply@databricks.com>
|
/review |
There was a problem hiding this comment.
Automated review at f227b4e. Each finding was verified against the code.
No blocking issues found. 2 non-blocking comment(s) and 1 question(s) below.
This PR makes air run -o json report config-validation, workspace-client and dry-run credential failures as JSON error envelopes. It sorts them into INVALID_ARGS, UNAUTHENTICATED and a new PERMISSION_DENIED code, and adds acceptance tests for each path. I traced the new branches and found no wrong behavior. Two small convention issues remain: a unit-test row that repeats an acceptance case, and doc comments that restate the switch. The open question is whether workspace-client classification should live in air run or in the shared authError.
Questions
renderWorkspaceClientErroradds a second classifier forMustWorkspaceClientfailures next toauthErrorincmd/air/get.go, and it repeats the same sentinel checks. As a result,air run -p does-not-exist -o jsonreports INVALID_ARGS/PERMANENT, whileair get/logs/poolsreport INTERNAL_ERROR/TRANSIENT/retryable for the same profile. Should the unknown-profile, account-only and expired-login cases move intoauthErrorso everyaircommand agrees? Or is a temporary per-command split until a follow-up acceptable? (non-blocking)
Changes
databricks air run -o jsonnow reports config-validation failures through the same JSON error envelope the otheraircommands use ({"v": 1, "ts": ..., "error": {"code": "INVALID_ARGS", "kind": "PERMANENT", "message": ..., "retryable": false}}) instead of plain text. This covers every validation step before a run is submitted: the local schema validation of the YAML config and--overridevalues (for examplemax_retries must be >= 0, got -1),code_sourcesnapshot resolution, the idempotency-token length check, and the backend field errors returned by--dry-run. Workspace-client, credential and permission failures are kept apart from config errors, so agents fix their access instead of editing a valid config, and-o jsongets the same envelope with or without--dry-run(asair get'sPreRunEdoes). A missing profile or rejected credentials go through the existingauthErrorhelper (UNAUTHENTICATED), an expired OAuth login isUNAUTHENTICATED, and a failure that may pass on retry (network, timeout, 429, 5xx) keepsauthError's retryable fallback. Other workspace-client setup failures, such as an unknown or account-only profile, areINVALID_ARGS/PERMANENT(scoped toair run). During--dry-run, a 401 or 403 from the current-user lookup and a 401 fromconfig:validateareUNAUTHENTICATED; a 403 fromconfig:validateisPERMISSION_DENIED/PERMANENT, since the same credentials just passed the current-user lookup. Noairenvelope had a permission code yet, so this one is named after the Databricks API'serror_code. Bundle diagnostics thatMustWorkspaceClientalready printed are reported once, without a second envelope.Why
Scripts and coding agents that pass
-o jsonexpect every outcome on stdout to be a JSON envelope. Config-validation errors were the oneair runfailure still printed asError: ...text, which broke those consumers (Jira CNXT-2683, found during the CUJ PE64 runthrough). The fix reuses the existingrenderErrorhelper, so the envelope shape is unchanged; text mode is unaffected (theauthErrorrewrite applies only with-o json).The
submitWorkloaderror on the non-dry-run path is left as is: it mixes artifact-upload and API failures with preflight validation, and none of the existing envelope codes describes all of them. Classifying those errors is a separate change.Scope decisions: the client-setup classification stays in
air run, because moving it into the sharedauthErrorwould also changeair get,logsandpools(air get -p does-not-exist -o jsonstill reportsauthError's retryable fallback until a follow-up does that).PERMISSION_DENIEDis added deliberately for aconfig:validate403, where reusingUNAUTHENTICATEDwould send agents to fix working credentials.Kept for parity with
air get: whendatabricks.ymlfails to load,-o jsonprints only the bundle diagnostics (stdout stays empty), becauseair getpasses the same already-printed error through; adding an envelope here alone would make the two commands disagree.Tests
-o jsoncases to theacceptance/air/run("invalid config is rejected (json)", "include_paths entry that selects no files is rejected (json)", "dry-run without credentials reports an authentication error (json)", "dry-run without credentials keeps the original error in text mode", "submit without credentials reports an authentication error (json)", "dry-run with an unknown profile is a permanent config error (json)", "dry-run reports an over-long idempotency key before missing credentials (json)", "bundle diagnostics are reported once (json)" with and without--dry-run), addedacceptance/air/run-rejected-credentialsfor the envelopes from a current-user 401/403 and aconfig:validate401/403 andacceptance/air/run-backend-error("backend field errors fail dry-run (json)") acceptance tests; regenerated their outputs with-update.TestRenderWorkspaceClientError: an expired login, a network failure, an account-only profile and an unknown profile each get the expected code andretryablevalue.go test ./acceptance -run TestAccept/air/passes.task lint-qandtask wsare clean.This pull request and its description were written by Isaac.