Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .nextchanges/air/run-json-validation-errors.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* `air run -o json` now reports config-validation errors as a JSON error envelope instead of plain text. A missing profile reports `UNAUTHENTICATED`, other workspace client setup errors (such as an unknown profile) report `INVALID_ARGS`, and with `--dry-run` rejected credentials report `UNAUTHENTICATED` and a missing permission on `config:validate` reports the new `PERMISSION_DENIED` code. ([#7864](https://github.com/databricks/cli/pull/7864))
14 changes: 14 additions & 0 deletions acceptance/air/run-backend-error/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,17 @@ Error: config validation failed:

Tip: use the --debug flag to see more details and a trace of this error:
databricks --debug air run …

=== backend field errors fail dry-run (json)

>>> [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
}
}
3 changes: 3 additions & 0 deletions acceptance/air/run-backend-error/script
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
title "backend field errors fail dry-run"
musterr trace $CLI air run -f valid.yaml --dry-run

title "backend field errors fail dry-run (json)"
musterr trace $CLI air run -f valid.yaml --dry-run -o json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Cloud = false
14 changes: 14 additions & 0 deletions acceptance/air/run-rejected-credentials/me-401/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

=== a 401 from the current-user lookup is rejected credentials (json)

>>> [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
}
}
2 changes: 2 additions & 0 deletions acceptance/air/run-rejected-credentials/me-401/script
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
title "a 401 from the current-user lookup is rejected credentials (json)"
musterr trace $CLI air run -f $TESTDIR/../valid.yaml --dry-run -o json
9 changes: 9 additions & 0 deletions acceptance/air/run-rejected-credentials/me-401/test.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[[Server]]
Pattern = "GET /api/2.0/preview/scim/v2/Me"
Response.Body = '''
{
"error_code": "UNAUTHENTICATED",
"message": "Invalid access token."
}
'''
Response.StatusCode = 401
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Cloud = false
14 changes: 14 additions & 0 deletions acceptance/air/run-rejected-credentials/me-403/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

=== a 403 from the current-user lookup is rejected credentials (json)

>>> [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
}
}
2 changes: 2 additions & 0 deletions acceptance/air/run-rejected-credentials/me-403/script
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
title "a 403 from the current-user lookup is rejected credentials (json)"
musterr trace $CLI air run -f $TESTDIR/../valid.yaml --dry-run -o json
9 changes: 9 additions & 0 deletions acceptance/air/run-rejected-credentials/me-403/test.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[[Server]]
Pattern = "GET /api/2.0/preview/scim/v2/Me"
Response.Body = '''
{
"error_code": "PERMISSION_DENIED",
"message": "Invalid access token."
}
'''
Response.StatusCode = 403
5 changes: 5 additions & 0 deletions acceptance/air/run-rejected-credentials/valid.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
experiment_name: smoke-test
command: python train.py
compute:
accelerator_type: GPU_1xH100
num_accelerators: 1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Cloud = false
14 changes: 14 additions & 0 deletions acceptance/air/run-rejected-credentials/validate-401/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

=== a 401 from config:validate is rejected credentials (json)

>>> [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
}
}
2 changes: 2 additions & 0 deletions acceptance/air/run-rejected-credentials/validate-401/script
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
title "a 401 from config:validate is rejected credentials (json)"
musterr trace $CLI air run -f $TESTDIR/../valid.yaml --dry-run -o json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[[Server]]
Pattern = "POST /api/2.0/ai-training/config:validate"
Response.Body = '''
{
"error_code": "UNAUTHENTICATED",
"message": "Invalid access token."
}
'''
Response.StatusCode = 401
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Cloud = false
14 changes: 14 additions & 0 deletions acceptance/air/run-rejected-credentials/validate-403/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

=== a 403 from config:validate is a missing permission (json)

>>> [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
}
}
2 changes: 2 additions & 0 deletions acceptance/air/run-rejected-credentials/validate-403/script
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
title "a 403 from config:validate is a missing permission (json)"
musterr trace $CLI air run -f $TESTDIR/../valid.yaml --dry-run -o json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[[Server]]
Pattern = "POST /api/2.0/ai-training/config:validate"
Response.Body = '''
{
"error_code": "PERMISSION_DENIED",
"message": "User does not have access to the accelerator pool."
}
'''
Response.StatusCode = 403
10 changes: 10 additions & 0 deletions acceptance/air/run/broken-bundle/databricks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
bundle:
name: broken-bundle

# Two targets both marked default is an invalid bundle, so loading it prints
# diagnostics before air run reaches the workspace.
targets:
dev:
default: true
dev2:
default: true
126 changes: 126 additions & 0 deletions acceptance/air/run/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,20 @@ Error: code_source include_paths select no files under [TEST_TMP_DIR]: data. Che
Tip: use the --debug flag to see more details and a trace of this error:
databricks --debug air run …

=== 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
}
}

=== include_paths pathspec that selects files outside root_path is rejected

>>> [CLI] air run -f include-outside-root.yaml --dry-run
Expand Down Expand Up @@ -120,6 +134,118 @@ Tip: use the --debug flag to see more details and a trace of this error:

Exit code: 1

=== 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
}
}

=== 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
}
}

=== 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
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 …

=== 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
}
}

=== 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
}
}

=== 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
}
}

=== bundle diagnostics are reported once (json)

>>> [CLI] air run -f ../valid.yaml --dry-run -o json
Error: multiple targets are marked as default ([TARGETS])


>>> [CLI] air run -f ../valid.yaml -o json
Error: multiple targets are marked as default ([TARGETS])


=== bundle diagnostics come before the idempotency key error

>>> [CLI] air run -f ../valid.yaml --dry-run --idempotency-key aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
Error: multiple targets are marked as default ([TARGETS])

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 …

>>> [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
}
}

=== unknown field suggests the near match

>>> [CLI] air run -f unknown-field.yaml --dry-run
Expand Down
3 changes: 3 additions & 0 deletions acceptance/air/run/profiles.databrickscfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[other]
host = https://other.test
token = other-token
29 changes: 29 additions & 0 deletions acceptance/air/run/script
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ trace $CLI air run -f with-code-source.yaml --dry-run
title "include_paths entry that selects no files is rejected"
musterr trace $CLI air run -f include-unmatched.yaml --dry-run

title "include_paths entry that selects no files is rejected (json)"
musterr trace $CLI air run -f include-unmatched.yaml --dry-run -o json

title "include_paths pathspec that selects files outside root_path is rejected"
# :(top) resolves against the repository root, so from root_path src it selects ../valid.yaml.
musterr trace $CLI air run -f include-outside-root.yaml --dry-run
Expand Down Expand Up @@ -62,6 +65,32 @@ errcode trace $CLI air run -f git-remote.yaml --dry-run
title "invalid config is rejected"
errcode trace $CLI air run -f invalid.yaml --dry-run

title "invalid config is rejected (json)"
musterr trace $CLI air run -f invalid.yaml --dry-run -o json

title "dry-run without credentials reports an authentication error (json)"
musterr trace env -u DATABRICKS_HOST -u DATABRICKS_TOKEN $CLI air run -f valid.yaml --dry-run -o json

title "dry-run without credentials keeps the original error in text mode"
musterr trace env -u DATABRICKS_HOST -u DATABRICKS_TOKEN $CLI air run -f valid.yaml --dry-run

title "submit without credentials reports an authentication error (json)"
musterr trace env -u DATABRICKS_HOST -u DATABRICKS_TOKEN $CLI air run -f valid.yaml -o json

title "dry-run reports an over-long idempotency key before missing credentials (json)"
musterr trace env -u DATABRICKS_HOST -u DATABRICKS_TOKEN $CLI air run -f valid.yaml --dry-run -o json --idempotency-key aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

title "dry-run with an unknown profile is a permanent config error (json)"
musterr trace 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

title "bundle diagnostics are reported once (json)"
musterr withdir broken-bundle trace $CLI air run -f ../valid.yaml --dry-run -o json
musterr withdir broken-bundle trace $CLI air run -f ../valid.yaml -o json

title "bundle diagnostics come before the idempotency key error"
musterr withdir broken-bundle trace $CLI air run -f ../valid.yaml --dry-run --idempotency-key aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
musterr withdir broken-bundle trace $CLI air run -f ../valid.yaml --dry-run -o json --idempotency-key aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

title "unknown field suggests the near match"
errcode trace $CLI air run -f unknown-field.yaml --dry-run

Expand Down
5 changes: 5 additions & 0 deletions acceptance/air/run/test.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
[[Server]]
Pattern = "POST /api/2.0/ai-training/config:validate"
Response.Body = '{}'

# The bundle loader lists default targets in map order.
[[Repls]]
Old = 'marked as default \((dev, dev2|dev2, dev)\)'
New = 'marked as default ([TARGETS])'
Loading
Loading