Skip to content

[AIR] CNXT-2683: Emit air run config-validation errors as JSON with -o json - #7864

Merged
vinchenzo-db merged 14 commits into
mainfrom
vinchenzo-db/cnxt-2683
Nov 23, 2026
Merged

vinchenzo-db merged 14 commits into
mainfrom
vinchenzo-db/cnxt-2683

Conversation

@vinchenzo-db

@vinchenzo-db vinchenzo-db commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Changes

databricks air run -o json now reports config-validation failures through the same JSON error envelope the other air commands 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 --override values (for example max_retries must be >= 0, got -1), code_source snapshot 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 json gets the same envelope with or without --dry-run (as air get's PreRunE does). A missing profile or rejected credentials go through the existing authError helper (UNAUTHENTICATED), an expired OAuth login is UNAUTHENTICATED, and a failure that may pass on retry (network, timeout, 429, 5xx) keeps authError's retryable fallback. Other workspace-client setup failures, such as an unknown or account-only profile, are INVALID_ARGS/PERMANENT (scoped to air run). During --dry-run, a 401 or 403 from the current-user lookup and a 401 from config:validate are UNAUTHENTICATED; a 403 from config:validate is PERMISSION_DENIED/PERMANENT, since the same credentials just passed the current-user lookup. No air envelope had a permission code yet, so this one is named after the Databricks API's error_code. Bundle diagnostics that MustWorkspaceClient already printed are reported once, without a second envelope.

Why

Scripts and coding agents that pass -o json expect every outcome on stdout to be a JSON envelope. Config-validation errors were the one air run failure still printed as Error: ... text, which broke those consumers (Jira CNXT-2683, found during the CUJ PE64 runthrough). The fix reuses the existing renderError helper, so the envelope shape is unchanged; text mode is unaffected (the authError rewrite applies only with -o json).

The submitWorkload error 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 shared authError would also change air get, logs and pools (air get -p does-not-exist -o json still reports authError's retryable fallback until a follow-up does that). PERMISSION_DENIED is added deliberately for a config:validate 403, where reusing UNAUTHENTICATED would send agents to fix working credentials.

Kept for parity with air get: when databricks.yml fails to load, -o json prints only the bundle diagnostics (stdout stays empty), because air get passes the same already-printed error through; adding an envelope here alone would make the two commands disagree.

Tests

  • Added -o json cases to the acceptance/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), added acceptance/air/run-rejected-credentials for the envelopes from a current-user 401/403 and a config:validate 401/403 and acceptance/air/run-backend-error ("backend field errors fail dry-run (json)") acceptance tests; regenerated their outputs with -update.
  • Added TestRenderWorkspaceClientError: an expired login, a network failure, an account-only profile and an unknown profile each get the expected code and retryable value.
  • go test ./acceptance -run TestAccept/air/ passes. task lint-q and task ws are clean.

This pull request and its description were written by Isaac.

vinchenzo-db and others added 2 commits November 21, 2026 03:37
`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>
@github-actions github-actions Bot added the AIR Databricks AI Runtime CLI label Nov 21, 2026
@vinchenzo-db
vinchenzo-db marked this pull request as ready for review November 21, 2026 03:38
@vinchenzo-db
vinchenzo-db requested review from a team as code owners November 21, 2026 03:38
@github-actions

github-actions Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Commit: f227b4ea5 | Workflow run

Regression test report

Selected 6 changed tests (limit=20, 0 not selected)

6 tests: regression=6 unreleased=0 coverage=0 failing=0
test branch main (8b7f43f) latest (v1.27.0)
TestAccept/air/run ✅ ❌ ❌
TestAccept/air/run-backend-error ✅ ❌ ❌
TestAccept/air/run-rejected-credentials/me-401 ✅ ❌ ❌
TestAccept/air/run-rejected-credentials/me-403 ✅ ❌ ❌
TestAccept/air/run-rejected-credentials/validate-401 ✅ ❌ ❌
TestAccept/air/run-rejected-credentials/validate-403 ✅ ❌ ❌
TestAccept/air/run: branch ✅ | main (8b7f43f) ❌ | latest (v1.27.0) ❌

main (8b7f43f):

acceptance_test.go:1402: Diff:
        --- air/run/output.txt
        +++ /tmp/TestAcceptairrun2554461752/002/output.txt
        @@ -66,17 +66,11 @@
         === include_paths entry that selects no files is rejected (json)
         
         >>> [CLI] air run -f include-unmatched.yaml --dry-run -o json
        -{
        -  "v": 1,
        -  "ts": "[TIMESTAMP]",
        -  "error": {
        -    "code": "INVALID_ARGS",
        -    "kind": "PERMANENT",
        -    "message": "code_source include_paths select no files under [TEST_TMP_DIR]: data. Check that these paths exist under root_path and hold files git does not ignore (`git check-ignore -v \u003cfile\u003e` shows the rule for a file); empty directories, nested git repositories and submodules add no files",
        -    "retryable": false
        -  }
        -}
        +Error: code_source include_paths select no files under [TEST_TMP_DIR]: data. Check that these paths exist under root_path and hold files git does not ignore (`git check-ignore -v <file>` shows the rule for a file); empty directories, nested git repositories and submodules add no files
         
        +Tip: use the --debug flag to see more details and a trace of this error:
        +  databricks --debug air run …
        +
         === include_paths pathspec that selects files outside root_path is rejected
         
         >>> [CLI] air run -f include-outside-root.yaml --dry-run
        @@ -137,31 +130,19 @@
         === invalid config is rejected (json)
         
         >>> [CLI] air run -f invalid.yaml --dry-run -o json
        -{
        -  "v": 1,
        -  "ts": "[TIMESTAMP]",
        -  "error": {
        -    "code": "INVALID_ARGS",
        -    "kind": "PERMANENT",
        -    "message": "invalid experiment_name \"bad.name\": only alphanumeric characters, hyphens (-), and underscores (_) are allowed",
        -    "retryable": false
        -  }
        -}
        +Error: invalid experiment_name "bad.name": only alphanumeric characters, hyphens (-), and underscores (_) are allowed
         
        +Tip: use the --debug flag to see more details and a trace of this error:
        +  databricks --debug air run …
        +
         === dry-run without credentials reports an authentication error (json)
         
         >>> env -u DATABRICKS_HOST -u DATABRICKS_TOKEN [CLI] air run -f valid.yaml --dry-run -o json
        -{
        -  "v": 1,
        -  "ts": "[TIMESTAMP]",
        -  "error": {
        -    "code": "UNAUTHENTICATED",
        -    "kind": "PERMANENT",
        -    "message": "no default profile is set: pass --profile (-p) or configure a default profile in your .databrickscfg",
        -    "retryable": false
        -  }
        -}
        +Error: default auth: cannot configure default credentials, please check https://docs.databricks.com/en/dev-tools/auth.html#databricks-client-unified-authentication to configure credentials for your preferred authentication method. Config: databricks_cli_path=[CLI]. Env: DATABRICKS_CLI_PATH
         
        +Tip: use the --debug flag to see more details and a trace of this error:
        +  databricks --debug air run …
        +
         === dry-run without credentials keeps the original error in text mode
         
         >>> env -u DATABRICKS_HOST -u DATABRICKS_TOKEN [CLI] air run -f valid.yaml --dry-run
        @@ -173,45 +149,24 @@
         === submit without credentials reports an authentication error (json)
         
         >>> env -u DATABRICKS_HOST -u DATABRICKS_TOKEN [CLI] air run -f valid.yaml -o json
        -{
        -  "v": 1,
        -  "ts": "[TIMESTAMP]",
        -  "error": {
        -    "code": "UNAUTHENTICATED",
        -    "kind": "PERMANENT",
        -    "message": "no default profile is set: pass --profile (-p) or configure a default profile in your .databrickscfg",
        -    "retryable": false
        -  }
        -}
        +Error: default auth: cannot configure default credentials, please check https://docs.databricks.com/en/dev-tools/auth.html#databricks-client-unified-authentication to configure credentials for your preferred authentication method. Config: databricks_cli_path=[CLI]. Env: DATABRICKS_CLI_PATH
         
         === dry-run reports an over-long idempotency key before missing credentials (json)
         
         >>> env -u DATABRICKS_HOST -u DATABRICKS_TOKEN [CLI] air run -f valid.yaml --dry-run -o json --idempotency-key aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
        -{
        -  "v": 1,
        -  "ts": "[TIMESTAMP]",
        -  "error": {
        -    "code": "INVALID_ARGS",
        -    "kind": "PERMANENT",
        -    "message": "idempotency token must be 64 characters or less, got 65",
        -    "retryable": false
        -  }
        -}
        +Error: idempotency token must be 64 characters or less, got 65
         
        +Tip: use the --debug flag to see more details and a trace of this error:
        +  databricks --debug air run …
        +
         === dry-run with an unknown profile is a permanent config error (json)
         
         >>> env -u DATABRICKS_HOST -u DATABRICKS_TOKEN DATABRICKS_CONFIG_FILE=profiles.databrickscfg [CLI] air run -f valid.yaml --dry-run -o json -p does-not-exist
        -{
        -  "v": 1,
        -  "ts": "[TIMESTAMP]",
        -  "error": {
        -    "code": "INVALID_ARGS",
        -    "kind": "PERMANENT",
        -    "message": "resolve: profiles.databrickscfg has no does-not-exist profile configured. Config: profile=does-not-exist, config_file=profiles.databrickscfg, databricks_cli_path=[CLI]. Env: DATABRICKS_CONFIG_FILE, DATABRICKS_CLI_PATH",
        -    "retryable": false
        -  }
        -}
        +Error: resolve: profiles.databrickscfg has no does-not-exist profile configured. Config: profile=does-not-exist, config_file=profiles.databrickscfg, databricks_cli_path=[CLI]. Env: DATABRICKS_CONFIG_FILE, DATABRICKS_CLI_PATH
         
        +Tip: use the --debug flag to see more details and a trace of this error:
        +  databricks --debug air run …
        +
         === bundle diagnostics are reported once (json)
         
         >>> [CLI] air run -f ../valid.yaml --dry-run -o json
        @@ -235,17 +181,11 @@
         >>> [CLI] air run -f ../valid.yaml --dry-run -o json --idempotency-key aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
         Error: multiple targets are marked as default ([TARGETS])
         
        -{
        -  "v": 1,
        -  "ts": "[TIMESTAMP]",
        -  "error": {
        -    "code": "INVALID_ARGS",
        -    "kind": "PERMANENT",
        -    "message": "idempotency token must be 64 characters or less, got 65",
        -    "retryable": false
        -  }
        -}
        +Error: idempotency token must be 64 characters or less, got 65
         
        +Tip: use the --debug flag to see more details and a trace of this error:
        +  databricks --debug air run …
        +
         === unknown field suggests the near match
         
         >>> [CLI] air run -f unknown-field.yaml --dry-run
        
FAIL

latest (v1.27.0):

acceptance_test.go:1402: Diff:
        --- air/run/output.txt
        +++ /tmp/TestAcceptairrun1324130834/002/output.txt
        @@ -66,17 +66,11 @@
         === include_paths entry that selects no files is rejected (json)
         
         >>> [CLI] air run -f include-unmatched.yaml --dry-run -o json
        -{
        -  "v": 1,
        -  "ts": "[TIMESTAMP]",
        -  "error": {
        -    "code": "INVALID_ARGS",
        -    "kind": "PERMANENT",
        -    "message": "code_source include_paths select no files under [TEST_TMP_DIR]: data. Check that these paths exist under root_path and hold files git does not ignore (`git check-ignore -v \u003cfile\u003e` shows the rule for a file); empty directories, nested git repositories and submodules add no files",
        -    "retryable": false
        -  }
        -}
        +Error: code_source include_paths select no files under [TEST_TMP_DIR]: data. Check that these paths exist under root_path and hold files git does not ignore (`git check-ignore -v <file>` shows the rule for a file); empty directories, nested git repositories and submodules add no files
         
        +Tip: use the --debug flag to see more details and a trace of this error:
        +  databricks --debug air run …
        +
         === include_paths pathspec that selects files outside root_path is rejected
         
         >>> [CLI] air run -f include-outside-root.yaml --dry-run
        @@ -137,31 +130,19 @@
         === invalid config is rejected (json)
         
         >>> [CLI] air run -f invalid.yaml --dry-run -o json
        -{
        -  "v": 1,
        -  "ts": "[TIMESTAMP]",
        -  "error": {
        -    "code": "INVALID_ARGS",
        -    "kind": "PERMANENT",
        -    "message": "invalid experiment_name \"bad.name\": only alphanumeric characters, hyphens (-), and underscores (_) are allowed",
        -    "retryable": false
        -  }
        -}
        +Error: invalid experiment_name "bad.name": only alphanumeric characters, hyphens (-), and underscores (_) are allowed
         
        +Tip: use the --debug flag to see more details and a trace of this error:
        +  databricks --debug air run …
        +
         === dry-run without credentials reports an authentication error (json)
         
         >>> env -u DATABRICKS_HOST -u DATABRICKS_TOKEN [CLI] air run -f valid.yaml --dry-run -o json
        -{
        -  "v": 1,
        -  "ts": "[TIMESTAMP]",
        -  "error": {
        -    "code": "UNAUTHENTICATED",
        -    "kind": "PERMANENT",
        -    "message": "no default profile is set: pass --profile (-p) or configure a default profile in your .databrickscfg",
        -    "retryable": false
        -  }
        -}
        +Error: default auth: cannot configure default credentials, please check https://docs.databricks.com/en/dev-tools/auth.html#databricks-client-unified-authentication to configure credentials for your preferred authentication method. Config: databricks_cli_path=[CLI]. Env: DATABRICKS_CLI_PATH
         
        +Tip: use the --debug flag to see more details and a trace of this error:
        +  databricks --debug air run …
        +
         === dry-run without credentials keeps the original error in text mode
         
         >>> env -u DATABRICKS_HOST -u DATABRICKS_TOKEN [CLI] air run -f valid.yaml --dry-run
        @@ -173,45 +149,24 @@
         === submit without credentials reports an authentication error (json)
         
         >>> env -u DATABRICKS_HOST -u DATABRICKS_TOKEN [CLI] air run -f valid.yaml -o json
        -{
        -  "v": 1,
        -  "ts": "[TIMESTAMP]",
        -  "error": {
        -    "code": "UNAUTHENTICATED",
        -    "kind": "PERMANENT",
        -    "message": "no default profile is set: pass --profile (-p) or configure a default profile in your .databrickscfg",
        -    "retryable": false
        -  }
        -}
        +Error: default auth: cannot configure default credentials, please check https://docs.databricks.com/en/dev-tools/auth.html#databricks-client-unified-authentication to configure credentials for your preferred authentication method. Config: databricks_cli_path=[CLI]. Env: DATABRICKS_CLI_PATH
         
         === dry-run reports an over-long idempotency key before missing credentials (json)
         
         >>> env -u DATABRICKS_HOST -u DATABRICKS_TOKEN [CLI] air run -f valid.yaml --dry-run -o json --idempotency-key aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
        -{
        -  "v": 1,
        -  "ts": "[TIMESTAMP]",
        -  "error": {
        -    "code": "INVALID_ARGS",
        -    "kind": "PERMANENT",
        -    "message": "idempotency token must be 64 characters or less, got 65",
        -    "retryable": false
        -  }
        -}
        +Error: idempotency token must be 64 characters or less, got 65
         
        +Tip: use the --debug flag to see more details and a trace of this error:
        +  databricks --debug air run …
        +
         === dry-run with an unknown profile is a permanent config error (json)
         
         >>> env -u DATABRICKS_HOST -u DATABRICKS_TOKEN DATABRICKS_CONFIG_FILE=profiles.databrickscfg [CLI] air run -f valid.yaml --dry-run -o json -p does-not-exist
        -{
        -  "v": 1,
        -  "ts": "[TIMESTAMP]",
        -  "error": {
        -    "code": "INVALID_ARGS",
        -    "kind": "PERMANENT",
        -    "message": "resolve: profiles.databrickscfg has no does-not-exist profile configured. Config: profile=does-not-exist, config_file=profiles.databrickscfg, databricks_cli_path=[CLI]. Env: DATABRICKS_CONFIG_FILE, DATABRICKS_CLI_PATH",
        -    "retryable": false
        -  }
        -}
        +Error: resolve: profiles.databrickscfg has no does-not-exist profile configured. Config: profile=does-not-exist, config_file=profiles.databrickscfg, databricks_cli_path=[CLI]. Env: DATABRICKS_CONFIG_FILE, DATABRICKS_CLI_PATH
         
        +Tip: use the --debug flag to see more details and a trace of this error:
        +  databricks --debug air run …
        +
         === bundle diagnostics are reported once (json)
         
         >>> [CLI] air run -f ../valid.yaml --dry-run -o json
        @@ -235,17 +181,11 @@
         >>> [CLI] air run -f ../valid.yaml --dry-run -o json --idempotency-key aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
         Error: multiple targets are marked as default ([TARGETS])
         
        -{
        -  "v": 1,
        -  "ts": "[TIMESTAMP]",
        -  "error": {
        -    "code": "INVALID_ARGS",
        -    "kind": "PERMANENT",
        -    "message": "idempotency token must be 64 characters or less, got 65",
        -    "retryable": false
        -  }
        -}
        +Error: idempotency token must be 64 characters or less, got 65
         
        +Tip: use the --debug flag to see more details and a trace of this error:
        +  databricks --debug air run …
        +
         === unknown field suggests the near match
         
         >>> [CLI] air run -f unknown-field.yaml --dry-run
        @@ -273,23 +212,8 @@
         === removed pool field is rejected
         
         >>> [CLI] air run -f removed-pool.yaml --dry-run
        -Error: invalid config removed-pool.yaml: line 6: unknown field "compute.pool_id"; did you mean "accelerator_pool_id"? Run "databricks air run -h config.compute" for the list of fields
        +Dry run: configuration for "smoke-test" is valid; not submitting.
         
        -Tip: use the --debug flag to see more details and a trace of this error:
        -  databricks --debug air run …
        +Unexpected success
         
        -=== unsupported priority is rejected
        -
        ->>> [CLI] air run -f invalid-priority.yaml --dry-run
        -Error: compute.priority_class: invalid priority_class "HIGH": valid values are: NORMAL
        -
        -Tip: use the --debug flag to see more details and a trace of this error:
        -  databricks --debug air run …
        -
        -=== priority without a pool is rejected
        -
        ->>> [CLI] air run -f priority-without-pool.yaml --dry-run
        -Error: compute.priority_class requires compute.accelerator_pool_id — priority applies only within a GPU Pool
        -
        -Tip: use the --debug flag to see more details and a trace of this error:
        -  databricks --debug air run …
        +Exit code: 1
        
FAIL
TestAccept/air/run-backend-error: branch ✅ | main (8b7f43f) ❌ | latest (v1.27.0) ❌

main (8b7f43f):

acceptance_test.go:1402: 
        	Error Trace:	/home/runner/work/cli/cli/libs/testdiff/testdiff.go:22
        	            				/home/runner/work/cli/cli/acceptance/acceptance_test.go:1402
        	            				/home/runner/work/cli/cli/acceptance/acceptance_test.go:1143
        	            				/home/runner/work/cli/cli/acceptance/acceptance_test.go:686
        	Error:      	Not equal: 
        	            	expected: "\n=== backend field errors fail dry-run\n\n>>> [CLI] air run -f valid.yaml --dry-run\nError: config validation failed:\n  deployments[0].compute.accelerator_count: accelerator_count must be at most 1024, but was 1032.\n  env_variables[1INVALID]: env_variables[1INVALID] contains characters that are not allowed.\n\nTip: use the --debug flag to see more details and a trace of this error:\n  databricks --debug air run …\n\n=== backend field errors fail dry-run (json)\n\n>>> [CLI] air run -f valid.yaml --dry-run -o json\n{\n  \"v\": 1,\n  \"ts\": \"[TIMESTAMP]\",\n  \"error\": {\n    \"code\": \"INVALID_ARGS\",\n    \"kind\": \"PERMANENT\",\n    \"message\": \"config validation failed:\\n  deployments[0].compute.accelerator_count: accelerator_count must be at most 1024, but was 1032.\\n  env_variables[1INVALID]: env_variables[1INVALID] contains characters that are not allowed.\",\n    \"retryable\": false\n  }\n}\n"
        	            	actual  : "\n=== backend field errors fail dry-run\n\n>>> [CLI] air run -f valid.yaml --dry-run\nError: config validation failed:\n  deployments[0].compute.accelerator_count: accelerator_count must be at most 1024, but was 1032.\n  env_variables[1INVALID]: env_variables[1INVALID] contains characters that are not allowed.\n\nTip: use the --debug flag to see more details and a trace of this error:\n  databricks --debug air run …\n\n=== backend field errors fail dry-run (json)\n\n>>> [CLI] air run -f valid.yaml --dry-run -o json\nError: config validation failed:\n  deployments[0].compute.accelerator_count: accelerator_count must be at most 1024, but was 1032.\n  env_variables[1INVALID]: env_variables[1INVALID] contains characters that are not allowed.\n\nTip: use the --debug flag to see more details and a trace of this error:\n  databricks --debug air run …\n"
        	            	
        	            	Diff:
        	            	--- Expected
        	            	+++ Actual
        	            	@@ -14,12 +14,8 @@
        	            	 >>> [CLI] air run -f valid.yaml --dry-run -o json
        	            	-{
        	            	-  "v": 1,
        	            	-  "ts": "[TIMESTAMP]",
        	            	-  "error": {
        	            	-    "code": "INVALID_ARGS",
        	            	-    "kind": "PERMANENT",
        	            	-    "message": "config validation failed:\n  deployments[0].compute.accelerator_count: accelerator_count must be at most 1024, but was 1032.\n  env_variables[1INVALID]: env_variables[1INVALID] contains characters that are not allowed.",
        	            	-    "retryable": false
        	            	-  }
        	            	-}
        	            	+Error: config validation failed:
        	            	+  deployments[0].compute.accelerator_count: accelerator_count must be at most 1024, but was 1032.
        	            	+  env_variables[1INVALID]: env_variables[1INVALID] contains characters that are not allowed.
        	            	 
        	            	+Tip: use the --debug flag to see more details and a trace of this error:
        	            	+  databricks --debug air run …
        	            	+
        	Test:       	TestAccept/air/run-backend-error
        	Messages:   	air/run-backend-error/output.txt vs /tmp/TestAcceptairrun-backend-error4130498001/002/output.txt

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):

acceptance_test.go:1402: 
        	Error Trace:	/home/runner/work/cli/cli/libs/testdiff/testdiff.go:22
        	            				/home/runner/work/cli/cli/acceptance/acceptance_test.go:1402
        	            				/home/runner/work/cli/cli/acceptance/acceptance_test.go:1143
        	            				/home/runner/work/cli/cli/acceptance/acceptance_test.go:686
        	Error:      	Not equal: 
        	            	expected: "\n=== a 401 from the current-user lookup is rejected credentials (json)\n\n>>> [CLI] air run -f [TESTROOT]/air/run-rejected-credentials/me-401/../valid.yaml --dry-run -o json\n{\n  \"v\": 1,\n  \"ts\": \"[TIMESTAMP]\",\n  \"error\": {\n    \"code\": \"UNAUTHENTICATED\",\n    \"kind\": \"PERMANENT\",\n    \"message\": \"authentication was not successful: failed to resolve current user: Invalid access token.\",\n    \"retryable\": false\n  }\n}\n"
        	            	actual  : "\n=== a 401 from the current-user lookup is rejected credentials (json)\n\n>>> [CLI] air run -f [TESTROOT]/air/run-rejected-credentials/me-401/../valid.yaml --dry-run -o json\nError: failed to resolve current user: Invalid access token.\n\nTip: use the --debug flag to see more details and a trace of this error:\n  databricks --debug air run …\n\nHost:      [DATABRICKS_URL]\nAuth type: Personal Access Token (pat)\n\nNext steps:\n  - Regenerate your access token\n  - Check your identity: databricks auth describe\n  - Consider setting up a profile: databricks auth login --profile <name>\n"
        	            	
        	            	Diff:
        	            	--- Expected
        	            	+++ Actual
        	            	@@ -4,12 +4,14 @@
        	            	 >>> [CLI] air run -f [TESTROOT]/air/run-rejected-credentials/me-401/../valid.yaml --dry-run -o json
        	            	-{
        	            	-  "v": 1,
        	            	-  "ts": "[TIMESTAMP]",
        	            	-  "error": {
        	            	-    "code": "UNAUTHENTICATED",
        	            	-    "kind": "PERMANENT",
        	            	-    "message": "authentication was not successful: failed to resolve current user: Invalid access token.",
        	            	-    "retryable": false
        	            	-  }
        	            	-}
        	            	+Error: failed to resolve current user: Invalid access token.
        	            	 
        	            	+Tip: use the --debug flag to see more details and a trace of this error:
        	            	+  databricks --debug air run …
        	            	+
        	            	+Host:      [DATABRICKS_URL]
        	            	+Auth type: Personal Access Token (pat)
        	            	+
        	            	+Next steps:
        	            	+  - Regenerate your access token
        	            	+  - Check your identity: databricks auth describe
        	            	+  - Consider setting up a profile: databricks auth login --profile <name>
        	            	+
        	Test:       	TestAccept/air/run-rejected-credentials/me-401
        	Messages:   	air/run-rejected-credentials/me-401/output.txt vs /tmp/TestAcceptairrun-rejected-credentialsme-4012771295423/002/output.txt

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):

acceptance_test.go:1402: 
        	Error Trace:	/home/runner/work/cli/cli/libs/testdiff/testdiff.go:22
        	            				/home/runner/work/cli/cli/acceptance/acceptance_test.go:1402
        	            				/home/runner/work/cli/cli/acceptance/acceptance_test.go:1143
        	            				/home/runner/work/cli/cli/acceptance/acceptance_test.go:686
        	Error:      	Not equal: 
        	            	expected: "\n=== a 403 from the current-user lookup is rejected credentials (json)\n\n>>> [CLI] air run -f [TESTROOT]/air/run-rejected-credentials/me-403/../valid.yaml --dry-run -o json\n{\n  \"v\": 1,\n  \"ts\": \"[TIMESTAMP]\",\n  \"error\": {\n    \"code\": \"UNAUTHENTICATED\",\n    \"kind\": \"PERMANENT\",\n    \"message\": \"authentication was not successful: failed to resolve current user: Invalid access token.\",\n    \"retryable\": false\n  }\n}\n"
        	            	actual  : "\n=== a 403 from the current-user lookup is rejected credentials (json)\n\n>>> [CLI] air run -f [TESTROOT]/air/run-rejected-credentials/me-403/../valid.yaml --dry-run -o json\nError: failed to resolve current user: Invalid access token.\n\nTip: use the --debug flag to see more details and a trace of this error:\n  databricks --debug air run …\n\nHost:      [DATABRICKS_URL]\nAuth type: Personal Access Token (pat)\n\nNext steps:\n  - Verify you have the required permissions for this operation\n  - Check your identity: databricks auth describe\n  - Consider setting up a profile: databricks auth login --profile <name>\n"
        	            	
        	            	Diff:
        	            	--- Expected
        	            	+++ Actual
        	            	@@ -4,12 +4,14 @@
        	            	 >>> [CLI] air run -f [TESTROOT]/air/run-rejected-credentials/me-403/../valid.yaml --dry-run -o json
        	            	-{
        	            	-  "v": 1,
        	            	-  "ts": "[TIMESTAMP]",
        	            	-  "error": {
        	            	-    "code": "UNAUTHENTICATED",
        	            	-    "kind": "PERMANENT",
        	            	-    "message": "authentication was not successful: failed to resolve current user: Invalid access token.",
        	            	-    "retryable": false
        	            	-  }
        	            	-}
        	            	+Error: failed to resolve current user: Invalid access token.
        	            	 
        	            	+Tip: use the --debug flag to see more details and a trace of this error:
        	            	+  databricks --debug air run …
        	            	+
        	            	+Host:      [DATABRICKS_URL]
        	            	+Auth type: Personal Access Token (pat)
        	            	+
        	            	+Next steps:
        	            	+  - Verify you have the required permissions for this operation
        	            	+  - Check your identity: databricks auth describe
        	            	+  - Consider setting up a profile: databricks auth login --profile <name>
        	            	+
        	Test:       	TestAccept/air/run-rejected-credentials/me-403
        	Messages:   	air/run-rejected-credentials/me-403/output.txt vs /tmp/TestAcceptairrun-rejected-credentialsme-4032984415504/002/output.txt

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):

acceptance_test.go:1402: 
        	Error Trace:	/home/runner/work/cli/cli/libs/testdiff/testdiff.go:22
        	            				/home/runner/work/cli/cli/acceptance/acceptance_test.go:1402
        	            				/home/runner/work/cli/cli/acceptance/acceptance_test.go:1143
        	            				/home/runner/work/cli/cli/acceptance/acceptance_test.go:686
        	Error:      	Not equal: 
        	            	expected: "\n=== a 401 from config:validate is rejected credentials (json)\n\n>>> [CLI] air run -f [TESTROOT]/air/run-rejected-credentials/validate-401/../valid.yaml --dry-run -o json\n{\n  \"v\": 1,\n  \"ts\": \"[TIMESTAMP]\",\n  \"error\": {\n    \"code\": \"UNAUTHENTICATED\",\n    \"kind\": \"PERMANENT\",\n    \"message\": \"authentication was not successful: failed to validate config: Invalid access token.\",\n    \"retryable\": false\n  }\n}\n"
        	            	actual  : "\n=== a 401 from config:validate is rejected credentials (json)\n\n>>> [CLI] air run -f [TESTROOT]/air/run-rejected-credentials/validate-401/../valid.yaml --dry-run -o json\nError: failed to validate config: Invalid access token.\n\nTip: use the --debug flag to see more details and a trace of this error:\n  databricks --debug air run …\n\nHost:      [DATABRICKS_URL]\nAuth type: Personal Access Token (pat)\n\nNext steps:\n  - Regenerate your access token\n  - Check your identity: databricks auth describe\n  - Consider setting up a profile: databricks auth login --profile <name>\n"
        	            	
        	            	Diff:
        	            	--- Expected
        	            	+++ Actual
        	            	@@ -4,12 +4,14 @@
        	            	 >>> [CLI] air run -f [TESTROOT]/air/run-rejected-credentials/validate-401/../valid.yaml --dry-run -o json
        	            	-{
        	            	-  "v": 1,
        	            	-  "ts": "[TIMESTAMP]",
        	            	-  "error": {
        	            	-    "code": "UNAUTHENTICATED",
        	            	-    "kind": "PERMANENT",
        	            	-    "message": "authentication was not successful: failed to validate config: Invalid access token.",
        	            	-    "retryable": false
        	            	-  }
        	            	-}
        	            	+Error: failed to validate config: Invalid access token.
        	            	 
        	            	+Tip: use the --debug flag to see more details and a trace of this error:
        	            	+  databricks --debug air run …
        	            	+
        	            	+Host:      [DATABRICKS_URL]
        	            	+Auth type: Personal Access Token (pat)
        	            	+
        	            	+Next steps:
        	            	+  - Regenerate your access token
        	            	+  - Check your identity: databricks auth describe
        	            	+  - Consider setting up a profile: databricks auth login --profile <name>
        	            	+
        	Test:       	TestAccept/air/run-rejected-credentials/validate-401
        	Messages:   	air/run-rejected-credentials/validate-401/output.txt vs /tmp/TestAcceptairrun-rejected-credentialsvalidate-4014205712762/002/output.txt

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):

acceptance_test.go:1402: 
        	Error Trace:	/home/runner/work/cli/cli/libs/testdiff/testdiff.go:22
        	            				/home/runner/work/cli/cli/acceptance/acceptance_test.go:1402
        	            				/home/runner/work/cli/cli/acceptance/acceptance_test.go:1143
        	            				/home/runner/work/cli/cli/acceptance/acceptance_test.go:686
        	Error:      	Not equal: 
        	            	expected: "\n=== a 403 from config:validate is a missing permission (json)\n\n>>> [CLI] air run -f [TESTROOT]/air/run-rejected-credentials/validate-403/../valid.yaml --dry-run -o json\n{\n  \"v\": 1,\n  \"ts\": \"[TIMESTAMP]\",\n  \"error\": {\n    \"code\": \"PERMISSION_DENIED\",\n    \"kind\": \"PERMANENT\",\n    \"message\": \"failed to validate config: User does not have access to the accelerator pool.\",\n    \"retryable\": false\n  }\n}\n"
        	            	actual  : "\n=== a 403 from config:validate is a missing permission (json)\n\n>>> [CLI] air run -f [TESTROOT]/air/run-rejected-credentials/validate-403/../valid.yaml --dry-run -o json\nError: failed to validate config: User does not have access to the accelerator pool.\n\nTip: use the --debug flag to see more details and a trace of this error:\n  databricks --debug air run …\n\nHost:      [DATABRICKS_URL]\nAuth type: Personal Access Token (pat)\n\nNext steps:\n  - Verify you have the required permissions for this operation\n  - Check your identity: databricks auth describe\n  - Consider setting up a profile: databricks auth login --profile <name>\n"
        	            	
        	            	Diff:
        	            	--- Expected
        	            	+++ Actual
        	            	@@ -4,12 +4,14 @@
        	            	 >>> [CLI] air run -f [TESTROOT]/air/run-rejected-credentials/validate-403/../valid.yaml --dry-run -o json
        	            	-{
        	            	-  "v": 1,
        	            	-  "ts": "[TIMESTAMP]",
        	            	-  "error": {
        	            	-    "code": "PERMISSION_DENIED",
        	            	-    "kind": "PERMANENT",
        	            	-    "message": "failed to validate config: User does not have access to the accelerator pool.",
        	            	-    "retryable": false
        	            	-  }
        	            	-}
        	            	+Error: failed to validate config: User does not have access to the accelerator pool.
        	            	 
        	            	+Tip: use the --debug flag to see more details and a trace of this error:
        	            	+  databricks --debug air run …
        	            	+
        	            	+Host:      [DATABRICKS_URL]
        	            	+Auth type: Personal Access Token (pat)
        	            	+
        	            	+Next steps:
        	            	+  - Verify you have the required permissions for this operation
        	            	+  - Check your identity: databricks auth describe
        	            	+  - Consider setting up a profile: databricks auth login --profile <name>
        	            	+
        	Test:       	TestAccept/air/run-rejected-credentials/validate-403
        	Messages:   	air/run-rejected-credentials/validate-403/output.txt vs /tmp/TestAcceptairrun-rejected-credentialsvalidate-403700372900/002/output.txt

latest (v1.27.0): same output as main (8b7f43f)

@review-oss-bot review-oss-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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) and validateIdempotencyToken (line 185) are inside the same dryRun block where lines 165 and 190 now call renderError, but these two still do a bare return err. With --dry-run -o json and a config that has code_source.snapshot pointing at a missing directory, or an invalid idempotency token, the CLI prints plain Error: … instead of a JSON envelope—the exact class of bug this PR fixes elsewhere. submitWorkload at line 221 has the same gap on the non-dry-run path. Wrap all three in renderError (it already no-ops in text mode), or add a single fallback wrapper at the RunE boundary so future error paths are covered automatically.

Comment thread acceptance/air/run/script Resolved
…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>
@vinchenzo-db

Copy link
Copy Markdown
Contributor Author

/review

@review-oss-bot review-oss-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Comment thread cmd/air/run.go Resolved
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>
@vinchenzo-db

Copy link
Copy Markdown
Contributor Author

/review

@eng-dev-ecosystem-bot

eng-dev-ecosystem-bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Integration test report

Commit: f227b4e

Run: 45252337215

Env 🔄​flaky 💚​RECOVERED ✅​pass 🙈​skip Time
💚​ aws linux-2core-8gb 1 272 25 15:16
💚​ aws-windows-latest-4core-16gb 1 274 23 10:25
💚​ azure linux-2core-8gb 1 271 25 14:05
🔄​ azure-windows-latest-4core-16gb 2 1 271 23 11:57
💚​ gcp linux-2core-8gb 1 272 25 18:26
💚​ gcp-windows-latest-4core-16gb 1 274 23 10:19
Test Name aws linux-2core-8gb aws-windows-latest-4core-16gb azure linux-2core-8gb azure-windows-latest-4core-16gb gcp linux-2core-8gb gcp-windows-latest-4core-16gb
💚​ TestAccept 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R
🔄​ TestFsCpDirToDirWithOverwriteFlag/dbfs_to_uc-volumes ✅​p ✅​p ✅​p 🔄​f ✅​p ✅​p
🔄​ TestFsCpDirToDirWithOverwriteFlag/uc-volumes_to_dbfs ✅​p ✅​p ✅​p 🔄​f ✅​p ✅​p
Top 44 slowest tests (at least 2 minutes):
duration env testname
4:50 gcp linux-2core-8gb TestFilerWorkspaceFilesExtensionsReadDir
4:38 azure-windows-latest-4core-16gb TestFilerWorkspaceFilesExtensionsDelete
4:29 aws linux-2core-8gb TestAccept
4:19 azure-windows-latest-4core-16gb TestSyncFullFileSync
4:07 azure-windows-latest-4core-16gb TestFilerWorkspaceFilesExtensionsStat
3:59 gcp-windows-latest-4core-16gb TestAccept
3:56 aws-windows-latest-4core-16gb TestAccept
3:48 azure linux-2core-8gb TestExportDir
3:46 gcp linux-2core-8gb TestFilerReadWrite/workspace_files_extensions
3:29 aws-windows-latest-4core-16gb TestFilerWorkspaceFilesExtensionsReadDir
3:23 azure linux-2core-8gb TestAccept
3:20 gcp linux-2core-8gb TestAccept
3:18 azure linux-2core-8gb TestImportDirWithOverwriteFlag
2:58 aws linux-2core-8gb TestImportDirWithOverwriteFlag
2:57 azure-windows-latest-4core-16gb TestFilerRecursiveDelete/workspace_files
2:57 azure-windows-latest-4core-16gb TestAccept
2:52 gcp linux-2core-8gb TestExportDir
2:49 azure linux-2core-8gb TestFilerWorkspaceFilesExtensionsStat
2:44 azure linux-2core-8gb TestFilerWorkspaceFilesExtensionsDelete
2:39 gcp-windows-latest-4core-16gb TestFilerWorkspaceFilesExtensionsRead
2:36 azure linux-2core-8gb TestFilerWorkspaceFilesExtensionsRead
2:36 gcp-windows-latest-4core-16gb TestFilerWorkspaceFilesExtensionsReadDir
2:33 azure-windows-latest-4core-16gb TestFilerWorkspaceFilesExtensionsReadDir
2:32 aws linux-2core-8gb TestFilerRecursiveDelete/workspace_files_extensions
2:28 gcp linux-2core-8gb TestImportDirDoesNotOverwrite
2:28 gcp-windows-latest-4core-16gb TestFilerWorkspaceFilesExtensionsDelete
2:27 gcp linux-2core-8gb TestFilerRecursiveDelete/workspace_files
2:27 aws linux-2core-8gb TestWorkspaceFilesExtensions_ExportFormatIsPreserved/jupyter_python
2:27 gcp linux-2core-8gb TestImportDir
2:25 azure-windows-latest-4core-16gb TestExportDir
2:24 azure linux-2core-8gb TestWorkspaceFilesExtensions_ExportFormatIsPreserved/source_r
2:24 aws-windows-latest-4core-16gb TestFilerRecursiveDelete/workspace_files_extensions
2:24 gcp-windows-latest-4core-16gb TestImportDirDoesNotOverwrite
2:23 gcp-windows-latest-4core-16gb TestFilerWorkspaceFilesExtensionsStat
2:17 aws linux-2core-8gb TestFilerWorkspaceFilesExtensionsReadDir
2:17 azure-windows-latest-4core-16gb TestFilerReadWrite/workspace_files
2:14 aws-windows-latest-4core-16gb TestLock
2:12 aws linux-2core-8gb TestFilerReadWrite/workspace_files
2:09 aws-windows-latest-4core-16gb TestFilerRecursiveDelete/workspace_files
2:08 gcp linux-2core-8gb TestFilerWorkspaceFilesExtensionsStat
2:07 azure linux-2core-8gb TestFilerWorkspaceNotebook/rNb.r
2:06 aws-windows-latest-4core-16gb TestFilerWorkspaceFilesExtensionsDelete
2:04 azure linux-2core-8gb TestFilerWorkspaceNotebook/pyNb.py
2:03 aws linux-2core-8gb TestFilerWorkspaceFilesExtensionsDelete

@vinchenzo-db

Copy link
Copy Markdown
Contributor Author

/review

1 similar comment
@vinchenzo-db

Copy link
Copy Markdown
Contributor Author

/review

Comment thread cmd/air/run.go Resolved
…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>
@vinchenzo-db

Copy link
Copy Markdown
Contributor Author

/review

@review-oss-bot review-oss-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Comment thread cmd/air/run.go Resolved
Comment thread cmd/air/run.go Resolved
Comment thread cmd/air/run.go Resolved
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>
@vinchenzo-db

Copy link
Copy Markdown
Contributor Author

/review

@review-oss-bot review-oss-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 broken databricks.yml is a static input, but the script builds it with mkdir/printf and deletes it afterwards. That goes against the testing rule "Commit static test inputs into the test directory instead of creating them in script". Can you commit acceptance/air/run/broken-bundle/databricks.yml and run the command with withdir broken-bundle ... instead?
  • [nit] .nextchanges/air/run-json-validation-errors.md:7: The entry only mentions config-validation errors. With -o json, --dry-run credential failures now also come back as UNAUTHENTICATED envelopes, and 403s get a new PERMISSION_DENIED code. Scripts that match on error.code will see both, so can the entry mention them?

Comment thread cmd/air/run.go Resolved
Comment thread cmd/air/run.go Resolved
… 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>
@vinchenzo-db

Copy link
Copy Markdown
Contributor Author

/review

@review-oss-bot review-oss-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Comment thread cmd/air/run.go Resolved
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>
@vinchenzo-db

Copy link
Copy Markdown
Contributor Author

/review

@review-oss-bot review-oss-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

  1. Without --dry-run, PreRunE (run.go:185) still returns MustWorkspaceClient errors unchanged. So air run -f x.yaml -o json with missing credentials prints Error: default auth: ... as text, while the same command with --dry-run now prints an UNAUTHENTICATED envelope. air get's PreRunE (get.go:196-202) already passes ErrAlreadyPrinted through and sends other failures to authError. Should air run's PreRunE do the same so both modes agree, or is that left for a follow-up? (non-blocking)
  2. When bundle loading fails (the "bundle diagnostics are reported once (json)" case), -o json prints the diagnostics as text and returns ErrAlreadyPrinted, leaving stdout empty. A JSON consumer gets a non-zero exit and nothing to parse. Is matching air get the intended behavior here, or should this path also print an envelope (for example INVALID_ARGS pointing at the bundle)? (non-blocking)

Comment thread cmd/air/run.go Resolved
…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>
@vinchenzo-db

Copy link
Copy Markdown
Contributor Author

/review

@review-oss-bot review-oss-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.md says 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/Me and config:validate, including the new PERMISSION_DENIED code, so the exact envelope text never lands in a golden file. Could these be acceptance cases next to acceptance/air/run-backend-error, which already stubs config:validate with [[Server]], using Response.StatusCode = 401/403 and an error_code body under musterr trace ... --dry-run -o json?

Comment thread cmd/air/run.go Resolved
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>
@vinchenzo-db

Copy link
Copy Markdown
Contributor Author

/review

@review-oss-bot review-oss-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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: The config validate/403 row checks the same thing as acceptance/air/run-permission-denied: a 403 PERMISSION_DENIED from config:validate under --dry-run -o json, expected as PERMISSION_DENIED/PERMANENT/non-retryable. .agents/rules/testing.md asks 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?

Comment thread cmd/air/run.go Resolved
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>
@vinchenzo-db

Copy link
Copy Markdown
Contributor Author

/review

@review-oss-bot review-oss-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

  1. renderWorkspaceClientError reports an unknown or account-only profile as INVALID_ARGS/PERMANENT, while air get -p does-not-exist -o json still goes through authError's fallback and reports INTERNAL_ERROR/TRANSIENT/retryable: true (get.go:149-150). So the same setup failure gets different codes from different air commands. Should this classification move into authError (or a shared helper air get's PreRunE also uses) so every command agrees, or stay scoped to air run with a follow-up for get? (non-blocking)
  2. PERMISSION_DENIED is a new envelope code that no other air command emits. air get reports an API 403 as UNAUTHENTICATED, and output.go says codes, kinds and retryable flags match the Python air CLI. Should the new code be added here (and documented for agents that branch on code, including the Python CLI and the skill text), or should a config:validate 403 reuse an existing code and leave the new one to its own change? (non-blocking)

Comment thread cmd/air/run_test.go Resolved
Comment thread cmd/air/run.go Resolved
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>
@vinchenzo-db

Copy link
Copy Markdown
Contributor Author

/review

@review-oss-bot review-oss-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 second Error: idempotency token .... With -o json, validateIdempotencyToken runs before the workspaceClientError branch, so stderr should get the diagnostics and stdout an INVALID_ARGS envelope, and nothing pins that. Can you add -o json here, or retitle the case if text mode was the intent?

Comment thread cmd/air/run.go Resolved
…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>
@vinchenzo-db

Copy link
Copy Markdown
Contributor Author

/review

@review-oss-bot review-oss-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

  1. renderWorkspaceClientError (cmd/air/run.go:101) re-checks the conditions authError (cmd/air/get.go:141) already checks, then adds an expired-login case and an INVALID_ARGS fallback that only air run uses. As a result, air run -p does-not-exist -o json reports INVALID_ARGS/retryable:false, while air get 1 -p does-not-exist -o json still reports INTERNAL_ERROR/retryable:true. The workspaceClientError and validationAuthenticationError wrappers exist only to route errors back into this logic. Should these cases go into authError in this PR so all air commands 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>
@vinchenzo-db

Copy link
Copy Markdown
Contributor Author

/review

@review-oss-bot review-oss-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

  1. renderWorkspaceClientError adds a second classifier for MustWorkspaceClient failures next to authError in cmd/air/get.go, and it repeats the same sentinel checks. As a result, air run -p does-not-exist -o json reports INVALID_ARGS/PERMANENT, while air get/logs/pools report INTERNAL_ERROR/TRANSIENT/retryable for the same profile. Should the unknown-profile, account-only and expired-login cases move into authError so every air command agrees? Or is a temporary per-command split until a follow-up acceptable? (non-blocking)

Comment thread cmd/air/run_test.go Resolved
Comment thread cmd/air/run.go Resolved
@vinchenzo-db
vinchenzo-db added this pull request to the merge queue Nov 23, 2026
Merged via the queue into main with commit 1ea5591 Nov 23, 2026
28 checks passed
@vinchenzo-db
vinchenzo-db deleted the vinchenzo-db/cnxt-2683 branch November 23, 2026 20:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AIR Databricks AI Runtime CLI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants