Repository navigation
[AIR] CNXT-2683: Emit air run config-validation errors as JSON with -o json - #7864
vinchenzo-db wants to merge 4 commits into
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 2 changed tests (limit=20, 0 not selected) 2 tests: regression=2 unreleased=0 coverage=0 failing=0
TestAccept/air/run: branch ✅ | main (1f1ab66) ❌ | latest (v1.27.0) ❌main (1f1ab66): latest (v1.27.0): TestAccept/air/run-backend-error: branch ✅ | main (1f1ab66) ❌ | latest (v1.27.0) ❌main (1f1ab66): latest (v1.27.0): same output as main (1f1ab66) |
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: 4d9b33d
Top 3 slowest tests (at least 2 minutes):
|
|
/review |
1 similar comment
|
/review |
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. A--dry-runthat cannot build an authenticated workspace client is reported asUNAUTHENTICATEDthrough the existingauthErrorhelper, like the otheraircommands.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.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.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)") andacceptance/air/run-backend-error("backend field errors fail dry-run (json)") acceptance tests; regenerated their outputs with-update.go test ./acceptance -run TestAccept/air/passes.task lint-qandtask wsare clean.This pull request and its description were written by Isaac.