From 5db2cba7b6cc6b914bee69747f02b99baea58a95 Mon Sep 17 00:00:00 2001 From: "pieter.noordhuis" Date: Mon, 30 Nov 2026 10:03:54 +0000 Subject: [PATCH 1/3] acceptance: name the api tests by what they cover Group the routing tests under a `routing-` prefix and the profile tests under `profile-`, and name the --json flag test `json`. The scripts and goldens are unchanged. Co-authored-by: Isaac --- acceptance/cmd/api/{account-flag => json}/out.test.toml | 0 acceptance/cmd/api/{request-handling => json}/output.txt | 0 acceptance/cmd/api/{request-handling => json}/script | 0 acceptance/cmd/api/{request-handling => json}/test.toml | 0 .../home/.databrickscfg | 0 .../api/{account-path => profile-default-vs-env}/out.test.toml | 0 .../{default-profile-vs-env => profile-default-vs-env}/output.txt | 0 .../api/{default-profile-vs-env => profile-default-vs-env}/script | 0 .../{default-profile-vs-env => profile-default-vs-env}/test.toml | 0 .../{default-profile => profile-default}/home/.databrickscfg.tmpl | 0 .../api/{default-profile-vs-env => profile-default}/out.test.toml | 0 .../cmd/api/{default-profile => profile-default}/output.txt | 0 acceptance/cmd/api/{default-profile => profile-default}/script | 0 acceptance/cmd/api/{default-profile => profile-default}/test.toml | 0 .../api/{default-profile => routing-account-flag}/out.test.toml | 0 .../cmd/api/{account-flag => routing-account-flag}/output.txt | 0 acceptance/cmd/api/{account-flag => routing-account-flag}/script | 0 .../api/{request-handling => routing-account-path}/out.test.toml | 0 .../cmd/api/{account-path => routing-account-path}/output.txt | 0 acceptance/cmd/api/{account-path => routing-account-path}/script | 0 .../out.test.toml | 0 .../output.txt | 0 .../script | 0 .../out.test.toml | 0 .../{workspace-id-flag => routing-workspace-id-flag}/output.txt | 0 .../api/{workspace-id-flag => routing-workspace-id-flag}/script | 0 .../home/.databrickscfg.tmpl | 0 .../out.test.toml | 0 .../{workspace-id-none => routing-workspace-id-none}/output.txt | 0 .../api/{workspace-id-none => routing-workspace-id-none}/script | 0 .../{workspace-id-none => routing-workspace-id-none}/test.toml | 0 .../out.test.toml | 0 .../output.txt | 0 .../script | 0 .../out.test.toml | 0 .../output.txt | 0 .../script | 0 .../out.test.toml | 0 .../cmd/api/{workspace-path => routing-workspace-path}/output.txt | 0 .../cmd/api/{workspace-path => routing-workspace-path}/script | 0 40 files changed, 0 insertions(+), 0 deletions(-) rename acceptance/cmd/api/{account-flag => json}/out.test.toml (100%) rename acceptance/cmd/api/{request-handling => json}/output.txt (100%) rename acceptance/cmd/api/{request-handling => json}/script (100%) rename acceptance/cmd/api/{request-handling => json}/test.toml (100%) rename acceptance/cmd/api/{default-profile-vs-env => profile-default-vs-env}/home/.databrickscfg (100%) rename acceptance/cmd/api/{account-path => profile-default-vs-env}/out.test.toml (100%) rename acceptance/cmd/api/{default-profile-vs-env => profile-default-vs-env}/output.txt (100%) rename acceptance/cmd/api/{default-profile-vs-env => profile-default-vs-env}/script (100%) rename acceptance/cmd/api/{default-profile-vs-env => profile-default-vs-env}/test.toml (100%) rename acceptance/cmd/api/{default-profile => profile-default}/home/.databrickscfg.tmpl (100%) rename acceptance/cmd/api/{default-profile-vs-env => profile-default}/out.test.toml (100%) rename acceptance/cmd/api/{default-profile => profile-default}/output.txt (100%) rename acceptance/cmd/api/{default-profile => profile-default}/script (100%) rename acceptance/cmd/api/{default-profile => profile-default}/test.toml (100%) rename acceptance/cmd/api/{default-profile => routing-account-flag}/out.test.toml (100%) rename acceptance/cmd/api/{account-flag => routing-account-flag}/output.txt (100%) rename acceptance/cmd/api/{account-flag => routing-account-flag}/script (100%) rename acceptance/cmd/api/{request-handling => routing-account-path}/out.test.toml (100%) rename acceptance/cmd/api/{account-path => routing-account-path}/output.txt (100%) rename acceptance/cmd/api/{account-path => routing-account-path}/script (100%) rename acceptance/cmd/api/{workspace-id-flag => routing-accounts-proxy-path}/out.test.toml (100%) rename acceptance/cmd/api/{workspace-proxy-regression => routing-accounts-proxy-path}/output.txt (100%) rename acceptance/cmd/api/{workspace-proxy-regression => routing-accounts-proxy-path}/script (100%) rename acceptance/cmd/api/{workspace-id-from-query => routing-workspace-id-flag}/out.test.toml (100%) rename acceptance/cmd/api/{workspace-id-flag => routing-workspace-id-flag}/output.txt (100%) rename acceptance/cmd/api/{workspace-id-flag => routing-workspace-id-flag}/script (100%) rename acceptance/cmd/api/{workspace-id-none => routing-workspace-id-none}/home/.databrickscfg.tmpl (100%) rename acceptance/cmd/api/{workspace-id-from-w-query => routing-workspace-id-none}/out.test.toml (100%) rename acceptance/cmd/api/{workspace-id-none => routing-workspace-id-none}/output.txt (100%) rename acceptance/cmd/api/{workspace-id-none => routing-workspace-id-none}/script (100%) rename acceptance/cmd/api/{workspace-id-none => routing-workspace-id-none}/test.toml (100%) rename acceptance/cmd/api/{workspace-id-none => routing-workspace-id-query-o}/out.test.toml (100%) rename acceptance/cmd/api/{workspace-id-from-query => routing-workspace-id-query-o}/output.txt (100%) rename acceptance/cmd/api/{workspace-id-from-query => routing-workspace-id-query-o}/script (100%) rename acceptance/cmd/api/{workspace-path => routing-workspace-id-query-w}/out.test.toml (100%) rename acceptance/cmd/api/{workspace-id-from-w-query => routing-workspace-id-query-w}/output.txt (100%) rename acceptance/cmd/api/{workspace-id-from-w-query => routing-workspace-id-query-w}/script (100%) rename acceptance/cmd/api/{workspace-proxy-regression => routing-workspace-path}/out.test.toml (100%) rename acceptance/cmd/api/{workspace-path => routing-workspace-path}/output.txt (100%) rename acceptance/cmd/api/{workspace-path => routing-workspace-path}/script (100%) diff --git a/acceptance/cmd/api/account-flag/out.test.toml b/acceptance/cmd/api/json/out.test.toml similarity index 100% rename from acceptance/cmd/api/account-flag/out.test.toml rename to acceptance/cmd/api/json/out.test.toml diff --git a/acceptance/cmd/api/request-handling/output.txt b/acceptance/cmd/api/json/output.txt similarity index 100% rename from acceptance/cmd/api/request-handling/output.txt rename to acceptance/cmd/api/json/output.txt diff --git a/acceptance/cmd/api/request-handling/script b/acceptance/cmd/api/json/script similarity index 100% rename from acceptance/cmd/api/request-handling/script rename to acceptance/cmd/api/json/script diff --git a/acceptance/cmd/api/request-handling/test.toml b/acceptance/cmd/api/json/test.toml similarity index 100% rename from acceptance/cmd/api/request-handling/test.toml rename to acceptance/cmd/api/json/test.toml diff --git a/acceptance/cmd/api/default-profile-vs-env/home/.databrickscfg b/acceptance/cmd/api/profile-default-vs-env/home/.databrickscfg similarity index 100% rename from acceptance/cmd/api/default-profile-vs-env/home/.databrickscfg rename to acceptance/cmd/api/profile-default-vs-env/home/.databrickscfg diff --git a/acceptance/cmd/api/account-path/out.test.toml b/acceptance/cmd/api/profile-default-vs-env/out.test.toml similarity index 100% rename from acceptance/cmd/api/account-path/out.test.toml rename to acceptance/cmd/api/profile-default-vs-env/out.test.toml diff --git a/acceptance/cmd/api/default-profile-vs-env/output.txt b/acceptance/cmd/api/profile-default-vs-env/output.txt similarity index 100% rename from acceptance/cmd/api/default-profile-vs-env/output.txt rename to acceptance/cmd/api/profile-default-vs-env/output.txt diff --git a/acceptance/cmd/api/default-profile-vs-env/script b/acceptance/cmd/api/profile-default-vs-env/script similarity index 100% rename from acceptance/cmd/api/default-profile-vs-env/script rename to acceptance/cmd/api/profile-default-vs-env/script diff --git a/acceptance/cmd/api/default-profile-vs-env/test.toml b/acceptance/cmd/api/profile-default-vs-env/test.toml similarity index 100% rename from acceptance/cmd/api/default-profile-vs-env/test.toml rename to acceptance/cmd/api/profile-default-vs-env/test.toml diff --git a/acceptance/cmd/api/default-profile/home/.databrickscfg.tmpl b/acceptance/cmd/api/profile-default/home/.databrickscfg.tmpl similarity index 100% rename from acceptance/cmd/api/default-profile/home/.databrickscfg.tmpl rename to acceptance/cmd/api/profile-default/home/.databrickscfg.tmpl diff --git a/acceptance/cmd/api/default-profile-vs-env/out.test.toml b/acceptance/cmd/api/profile-default/out.test.toml similarity index 100% rename from acceptance/cmd/api/default-profile-vs-env/out.test.toml rename to acceptance/cmd/api/profile-default/out.test.toml diff --git a/acceptance/cmd/api/default-profile/output.txt b/acceptance/cmd/api/profile-default/output.txt similarity index 100% rename from acceptance/cmd/api/default-profile/output.txt rename to acceptance/cmd/api/profile-default/output.txt diff --git a/acceptance/cmd/api/default-profile/script b/acceptance/cmd/api/profile-default/script similarity index 100% rename from acceptance/cmd/api/default-profile/script rename to acceptance/cmd/api/profile-default/script diff --git a/acceptance/cmd/api/default-profile/test.toml b/acceptance/cmd/api/profile-default/test.toml similarity index 100% rename from acceptance/cmd/api/default-profile/test.toml rename to acceptance/cmd/api/profile-default/test.toml diff --git a/acceptance/cmd/api/default-profile/out.test.toml b/acceptance/cmd/api/routing-account-flag/out.test.toml similarity index 100% rename from acceptance/cmd/api/default-profile/out.test.toml rename to acceptance/cmd/api/routing-account-flag/out.test.toml diff --git a/acceptance/cmd/api/account-flag/output.txt b/acceptance/cmd/api/routing-account-flag/output.txt similarity index 100% rename from acceptance/cmd/api/account-flag/output.txt rename to acceptance/cmd/api/routing-account-flag/output.txt diff --git a/acceptance/cmd/api/account-flag/script b/acceptance/cmd/api/routing-account-flag/script similarity index 100% rename from acceptance/cmd/api/account-flag/script rename to acceptance/cmd/api/routing-account-flag/script diff --git a/acceptance/cmd/api/request-handling/out.test.toml b/acceptance/cmd/api/routing-account-path/out.test.toml similarity index 100% rename from acceptance/cmd/api/request-handling/out.test.toml rename to acceptance/cmd/api/routing-account-path/out.test.toml diff --git a/acceptance/cmd/api/account-path/output.txt b/acceptance/cmd/api/routing-account-path/output.txt similarity index 100% rename from acceptance/cmd/api/account-path/output.txt rename to acceptance/cmd/api/routing-account-path/output.txt diff --git a/acceptance/cmd/api/account-path/script b/acceptance/cmd/api/routing-account-path/script similarity index 100% rename from acceptance/cmd/api/account-path/script rename to acceptance/cmd/api/routing-account-path/script diff --git a/acceptance/cmd/api/workspace-id-flag/out.test.toml b/acceptance/cmd/api/routing-accounts-proxy-path/out.test.toml similarity index 100% rename from acceptance/cmd/api/workspace-id-flag/out.test.toml rename to acceptance/cmd/api/routing-accounts-proxy-path/out.test.toml diff --git a/acceptance/cmd/api/workspace-proxy-regression/output.txt b/acceptance/cmd/api/routing-accounts-proxy-path/output.txt similarity index 100% rename from acceptance/cmd/api/workspace-proxy-regression/output.txt rename to acceptance/cmd/api/routing-accounts-proxy-path/output.txt diff --git a/acceptance/cmd/api/workspace-proxy-regression/script b/acceptance/cmd/api/routing-accounts-proxy-path/script similarity index 100% rename from acceptance/cmd/api/workspace-proxy-regression/script rename to acceptance/cmd/api/routing-accounts-proxy-path/script diff --git a/acceptance/cmd/api/workspace-id-from-query/out.test.toml b/acceptance/cmd/api/routing-workspace-id-flag/out.test.toml similarity index 100% rename from acceptance/cmd/api/workspace-id-from-query/out.test.toml rename to acceptance/cmd/api/routing-workspace-id-flag/out.test.toml diff --git a/acceptance/cmd/api/workspace-id-flag/output.txt b/acceptance/cmd/api/routing-workspace-id-flag/output.txt similarity index 100% rename from acceptance/cmd/api/workspace-id-flag/output.txt rename to acceptance/cmd/api/routing-workspace-id-flag/output.txt diff --git a/acceptance/cmd/api/workspace-id-flag/script b/acceptance/cmd/api/routing-workspace-id-flag/script similarity index 100% rename from acceptance/cmd/api/workspace-id-flag/script rename to acceptance/cmd/api/routing-workspace-id-flag/script diff --git a/acceptance/cmd/api/workspace-id-none/home/.databrickscfg.tmpl b/acceptance/cmd/api/routing-workspace-id-none/home/.databrickscfg.tmpl similarity index 100% rename from acceptance/cmd/api/workspace-id-none/home/.databrickscfg.tmpl rename to acceptance/cmd/api/routing-workspace-id-none/home/.databrickscfg.tmpl diff --git a/acceptance/cmd/api/workspace-id-from-w-query/out.test.toml b/acceptance/cmd/api/routing-workspace-id-none/out.test.toml similarity index 100% rename from acceptance/cmd/api/workspace-id-from-w-query/out.test.toml rename to acceptance/cmd/api/routing-workspace-id-none/out.test.toml diff --git a/acceptance/cmd/api/workspace-id-none/output.txt b/acceptance/cmd/api/routing-workspace-id-none/output.txt similarity index 100% rename from acceptance/cmd/api/workspace-id-none/output.txt rename to acceptance/cmd/api/routing-workspace-id-none/output.txt diff --git a/acceptance/cmd/api/workspace-id-none/script b/acceptance/cmd/api/routing-workspace-id-none/script similarity index 100% rename from acceptance/cmd/api/workspace-id-none/script rename to acceptance/cmd/api/routing-workspace-id-none/script diff --git a/acceptance/cmd/api/workspace-id-none/test.toml b/acceptance/cmd/api/routing-workspace-id-none/test.toml similarity index 100% rename from acceptance/cmd/api/workspace-id-none/test.toml rename to acceptance/cmd/api/routing-workspace-id-none/test.toml diff --git a/acceptance/cmd/api/workspace-id-none/out.test.toml b/acceptance/cmd/api/routing-workspace-id-query-o/out.test.toml similarity index 100% rename from acceptance/cmd/api/workspace-id-none/out.test.toml rename to acceptance/cmd/api/routing-workspace-id-query-o/out.test.toml diff --git a/acceptance/cmd/api/workspace-id-from-query/output.txt b/acceptance/cmd/api/routing-workspace-id-query-o/output.txt similarity index 100% rename from acceptance/cmd/api/workspace-id-from-query/output.txt rename to acceptance/cmd/api/routing-workspace-id-query-o/output.txt diff --git a/acceptance/cmd/api/workspace-id-from-query/script b/acceptance/cmd/api/routing-workspace-id-query-o/script similarity index 100% rename from acceptance/cmd/api/workspace-id-from-query/script rename to acceptance/cmd/api/routing-workspace-id-query-o/script diff --git a/acceptance/cmd/api/workspace-path/out.test.toml b/acceptance/cmd/api/routing-workspace-id-query-w/out.test.toml similarity index 100% rename from acceptance/cmd/api/workspace-path/out.test.toml rename to acceptance/cmd/api/routing-workspace-id-query-w/out.test.toml diff --git a/acceptance/cmd/api/workspace-id-from-w-query/output.txt b/acceptance/cmd/api/routing-workspace-id-query-w/output.txt similarity index 100% rename from acceptance/cmd/api/workspace-id-from-w-query/output.txt rename to acceptance/cmd/api/routing-workspace-id-query-w/output.txt diff --git a/acceptance/cmd/api/workspace-id-from-w-query/script b/acceptance/cmd/api/routing-workspace-id-query-w/script similarity index 100% rename from acceptance/cmd/api/workspace-id-from-w-query/script rename to acceptance/cmd/api/routing-workspace-id-query-w/script diff --git a/acceptance/cmd/api/workspace-proxy-regression/out.test.toml b/acceptance/cmd/api/routing-workspace-path/out.test.toml similarity index 100% rename from acceptance/cmd/api/workspace-proxy-regression/out.test.toml rename to acceptance/cmd/api/routing-workspace-path/out.test.toml diff --git a/acceptance/cmd/api/workspace-path/output.txt b/acceptance/cmd/api/routing-workspace-path/output.txt similarity index 100% rename from acceptance/cmd/api/workspace-path/output.txt rename to acceptance/cmd/api/routing-workspace-path/output.txt diff --git a/acceptance/cmd/api/workspace-path/script b/acceptance/cmd/api/routing-workspace-path/script similarity index 100% rename from acceptance/cmd/api/workspace-path/script rename to acceptance/cmd/api/routing-workspace-path/script From 2efc3be213c79dd2b160722093527e34de611744 Mon Sep 17 00:00:00 2001 From: "pieter.noordhuis" Date: Mon, 30 Nov 2026 10:04:04 +0000 Subject: [PATCH 2/3] acceptance: pin the wire behavior of `databricks api` Before the HTTP layer under `databricks api` is replaced, record what the command does today: the request sent for every method with and without --json (methods), the shapes of --json input (json), how JSON bodies are rendered (response-json) and what happens to other bodies (response-text), how HTTP errors are rendered and which are retried (errors), how the PATH argument becomes a URL (url), flag validation (flags), and the --debug output (debug). Co-authored-by: Isaac --- .../out.test.toml | 0 acceptance/cmd/api/debug/output.txt | 68 ++++ acceptance/cmd/api/debug/script | 11 + acceptance/cmd/api/debug/test.toml | 13 + acceptance/cmd/api/errors/out.test.toml | 1 + acceptance/cmd/api/errors/output.txt | 65 +++ acceptance/cmd/api/errors/script | 32 ++ acceptance/cmd/api/errors/test.toml | 21 + acceptance/cmd/api/flags/out.test.toml | 1 + acceptance/cmd/api/flags/output.txt | 78 ++++ acceptance/cmd/api/flags/script | 23 ++ acceptance/cmd/api/json/body.json | 1 + acceptance/cmd/api/json/output.txt | 100 +++++ acceptance/cmd/api/json/script | 28 ++ acceptance/cmd/api/methods/out.test.toml | 1 + acceptance/cmd/api/methods/output.txt | 380 ++++++++++++++++++ acceptance/cmd/api/methods/script | 13 + acceptance/cmd/api/methods/test.toml | 3 + .../cmd/api/response-handling/output.txt | 20 - .../cmd/api/response-handling/test.toml | 18 - .../cmd/api/response-json/out.test.toml | 1 + acceptance/cmd/api/response-json/output.txt | 72 ++++ acceptance/cmd/api/response-json/script | 34 ++ acceptance/cmd/api/response-json/test.toml | 39 ++ .../cmd/api/response-text/out.test.toml | 1 + acceptance/cmd/api/response-text/output.txt | 14 + .../script | 18 +- acceptance/cmd/api/response-text/test.toml | 17 + acceptance/cmd/api/test.toml | 30 ++ acceptance/cmd/api/url/out.test.toml | 1 + acceptance/cmd/api/url/output.txt | 52 +++ acceptance/cmd/api/url/script | 16 + 32 files changed, 1125 insertions(+), 47 deletions(-) rename acceptance/cmd/api/{response-handling => debug}/out.test.toml (100%) create mode 100644 acceptance/cmd/api/debug/output.txt create mode 100644 acceptance/cmd/api/debug/script create mode 100644 acceptance/cmd/api/debug/test.toml create mode 100644 acceptance/cmd/api/errors/out.test.toml create mode 100644 acceptance/cmd/api/errors/output.txt create mode 100644 acceptance/cmd/api/errors/script create mode 100644 acceptance/cmd/api/errors/test.toml create mode 100644 acceptance/cmd/api/flags/out.test.toml create mode 100644 acceptance/cmd/api/flags/output.txt create mode 100644 acceptance/cmd/api/flags/script create mode 100644 acceptance/cmd/api/json/body.json create mode 100644 acceptance/cmd/api/methods/out.test.toml create mode 100644 acceptance/cmd/api/methods/output.txt create mode 100644 acceptance/cmd/api/methods/script create mode 100644 acceptance/cmd/api/methods/test.toml delete mode 100644 acceptance/cmd/api/response-handling/output.txt delete mode 100644 acceptance/cmd/api/response-handling/test.toml create mode 100644 acceptance/cmd/api/response-json/out.test.toml create mode 100644 acceptance/cmd/api/response-json/output.txt create mode 100644 acceptance/cmd/api/response-json/script create mode 100644 acceptance/cmd/api/response-json/test.toml create mode 100644 acceptance/cmd/api/response-text/out.test.toml create mode 100644 acceptance/cmd/api/response-text/output.txt rename acceptance/cmd/api/{response-handling => response-text}/script (54%) create mode 100644 acceptance/cmd/api/response-text/test.toml create mode 100644 acceptance/cmd/api/url/out.test.toml create mode 100644 acceptance/cmd/api/url/output.txt create mode 100644 acceptance/cmd/api/url/script diff --git a/acceptance/cmd/api/response-handling/out.test.toml b/acceptance/cmd/api/debug/out.test.toml similarity index 100% rename from acceptance/cmd/api/response-handling/out.test.toml rename to acceptance/cmd/api/debug/out.test.toml diff --git a/acceptance/cmd/api/debug/output.txt b/acceptance/cmd/api/debug/output.txt new file mode 100644 index 00000000000..cb92d70e14c --- /dev/null +++ b/acceptance/cmd/api/debug/output.txt @@ -0,0 +1,68 @@ + +=== GET with --json + +>>> [CLI] api get /api/2.0/test/echo --json {"id": 7} --debug +HH:MM:SS Info: start pid=PID version=[CLI_VERSION] args="[CLI], api, get, /api/2.0/test/echo, --json, {\"id\": 7}, --debug" +HH:MM:SS Debug: [Local Cache] using cache key: [SHA256_HASH] pid=PID +HH:MM:SS Debug: [Local Cache] cache miss, computing pid=PID +HH:MM:SS Debug: GET /.well-known/databricks-config +< HTTP/1.1 200 OK +< { +< "oidc_endpoint": "[DATABRICKS_URL]/oidc", +< "workspace_id": "[WORKSPACE_ID]" +< } pid=PID sdk=true +HH:MM:SS Debug: [Local Cache] computed and stored result pid=PID +HH:MM:SS Debug: Resolved workspace_id from host metadata: "[WORKSPACE_ID]" pid=PID sdk=true +HH:MM:SS Debug: Resolved cloud from hostname: "AWS" pid=PID sdk=true +HH:MM:SS Debug: Resolved discovery_url from host metadata: "[DATABRICKS_URL]/oidc/.well-known/oauth-authorization-server" pid=PID sdk=true +HH:MM:SS Debug: GET /api/2.0/test/echo?id=7 +< HTTP/1.1 200 OK +< { +< "ok": true +< } pid=PID sdk=true +{ + "ok": true +} +HH:MM:SS Info: completed execution pid=PID exit_code=0 +HH:MM:SS Debug: no telemetry logs to upload pid=PID + +=== POST with --json + +>>> [CLI] api post /api/2.0/test/echo --json {"id": 7} --debug +HH:MM:SS Info: start pid=PID version=[CLI_VERSION] args="[CLI], api, post, /api/2.0/test/echo, --json, {\"id\": 7}, --debug" +HH:MM:SS Debug: [Local Cache] using cache key: [SHA256_HASH] pid=PID +HH:MM:SS Debug: [Local Cache] cache hit pid=PID +HH:MM:SS Debug: Resolved workspace_id from host metadata: "[WORKSPACE_ID]" pid=PID sdk=true +HH:MM:SS Debug: Resolved cloud from hostname: "AWS" pid=PID sdk=true +HH:MM:SS Debug: Resolved discovery_url from host metadata: "[DATABRICKS_URL]/oidc/.well-known/oauth-authorization-server" pid=PID sdk=true +HH:MM:SS Debug: POST /api/2.0/test/echo +> { +> "id": 7 +> } +< HTTP/1.1 200 OK +< { +< "ok": true +< } pid=PID sdk=true +{ + "ok": true +} +HH:MM:SS Info: completed execution pid=PID exit_code=0 +HH:MM:SS Debug: no telemetry logs to upload pid=PID + +=== Error response +HH:MM:SS Info: start pid=PID version=[CLI_VERSION] args="[CLI], api, get, /api/2.0/test/err404, --debug" +HH:MM:SS Debug: [Local Cache] using cache key: [SHA256_HASH] pid=PID +HH:MM:SS Debug: [Local Cache] cache hit pid=PID +HH:MM:SS Debug: Resolved workspace_id from host metadata: "[WORKSPACE_ID]" pid=PID sdk=true +HH:MM:SS Debug: Resolved cloud from hostname: "AWS" pid=PID sdk=true +HH:MM:SS Debug: Resolved discovery_url from host metadata: "[DATABRICKS_URL]/oidc/.well-known/oauth-authorization-server" pid=PID sdk=true +HH:MM:SS Debug: GET /api/2.0/test/err404 +< HTTP/1.1 404 Not Found +< { +< "error_code": "RESOURCE_DOES_NOT_EXIST", +< "message": "Not found" +< } pid=PID sdk=true +HH:MM:SS Debug: non-retriable error: Not found pid=PID sdk=true +Error: Not found +HH:MM:SS Info: failed execution pid=PID exit_code=1 error="Not found" +HH:MM:SS Debug: no telemetry logs to upload pid=PID diff --git a/acceptance/cmd/api/debug/script b/acceptance/cmd/api/debug/script new file mode 100644 index 00000000000..db9914ab8ef --- /dev/null +++ b/acceptance/cmd/api/debug/script @@ -0,0 +1,11 @@ +# What --debug prints for a request: the resolved configuration, the outgoing +# request and the response, including bodies. + +title "GET with --json" +MSYS_NO_PATHCONV=1 trace $CLI api get /api/2.0/test/echo --json '{"id": 7}' --debug 2>&1 + +title "POST with --json" +MSYS_NO_PATHCONV=1 trace $CLI api post /api/2.0/test/echo --json '{"id": 7}' --debug 2>&1 + +title "Error response" +MSYS_NO_PATHCONV=1 musterr $CLI api get /api/2.0/test/err404 --debug 2>&1 diff --git a/acceptance/cmd/api/debug/test.toml b/acceptance/cmd/api/debug/test.toml new file mode 100644 index 00000000000..dbcec41e41e --- /dev/null +++ b/acceptance/cmd/api/debug/test.toml @@ -0,0 +1,13 @@ +# --debug output carries the process id, wall-clock timestamps and the +# host-metadata cache key, which hashes the test server URL (random port). +[[Repls]] +Old = "pid=[0-9]+" +New = "pid=PID" + +[[Repls]] +Old = "(?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]" +New = "HH:MM:SS" + +[[Repls]] +Old = "[0-9a-f]{64}" +New = "[SHA256_HASH]" diff --git a/acceptance/cmd/api/errors/out.test.toml b/acceptance/cmd/api/errors/out.test.toml new file mode 100644 index 00000000000..18b1a88417e --- /dev/null +++ b/acceptance/cmd/api/errors/out.test.toml @@ -0,0 +1 @@ +Cloud = false diff --git a/acceptance/cmd/api/errors/output.txt b/acceptance/cmd/api/errors/output.txt new file mode 100644 index 00000000000..4ddec16fad4 --- /dev/null +++ b/acceptance/cmd/api/errors/output.txt @@ -0,0 +1,65 @@ + +=== 400 with a standard error body +Error: Cluster abc does not exist + +Exit code: 1 + +=== 403 with a plain-text body +Error: Forbidden + +Exit code: 1 + +=== 404 with a standard error body +Error: Not found + +Exit code: 1 + +=== 409 on a POST +Error: Branch exists + +Exit code: 1 + +=== 500 with an HTML body is not retried +Error: Internal Server Error + +Exit code: 1 + +>>> print_requests.py --get //test/err500 --del-field headers +{ + "method": "GET", + "path": "/api/2.0/test/err500" +} + +=== 429 is retried + +>>> [CLI] api get /api/2.0/test/echo +{ + "ok": true +} + +>>> print_requests.py --get //test/echo --del-field headers +{ + "method": "GET", + "path": "/api/2.0/test/echo" +} +{ + "method": "GET", + "path": "/api/2.0/test/echo" +} + +=== 503 is retried + +>>> [CLI] api get /api/2.0/test/echo +{ + "ok": true +} + +>>> print_requests.py --get //test/echo --del-field headers +{ + "method": "GET", + "path": "/api/2.0/test/echo" +} +{ + "method": "GET", + "path": "/api/2.0/test/echo" +} diff --git a/acceptance/cmd/api/errors/script b/acceptance/cmd/api/errors/script new file mode 100644 index 00000000000..62e938d2bbf --- /dev/null +++ b/acceptance/cmd/api/errors/script @@ -0,0 +1,32 @@ +# How HTTP error responses are rendered, their exit codes, and which are retried. + +title "400 with a standard error body" +MSYS_NO_PATHCONV=1 musterr $CLI api get /api/2.0/test/err400 +printf '\nExit code: %s\n' "$MUSTERR_EXIT_CODE" + +title "403 with a plain-text body" +MSYS_NO_PATHCONV=1 musterr $CLI api get /api/2.0/test/err403 +printf '\nExit code: %s\n' "$MUSTERR_EXIT_CODE" + +title "404 with a standard error body" +MSYS_NO_PATHCONV=1 musterr $CLI api get /api/2.0/test/err404 +printf '\nExit code: %s\n' "$MUSTERR_EXIT_CODE" + +title "409 on a POST" +MSYS_NO_PATHCONV=1 musterr $CLI api post /api/2.0/test/err409 --json '{"spec": {}}' +printf '\nExit code: %s\n' "$MUSTERR_EXIT_CODE" + +title "500 with an HTML body is not retried" +MSYS_NO_PATHCONV=1 musterr $CLI api get /api/2.0/test/err500 +printf '\nExit code: %s\n' "$MUSTERR_EXIT_CODE" +trace print_requests.py --get //test/err500 --del-field headers + +title "429 is retried" +fault.py "GET /api/2.0/test/echo" 429 0 1 +MSYS_NO_PATHCONV=1 trace $CLI api get /api/2.0/test/echo +trace print_requests.py --get //test/echo --del-field headers + +title "503 is retried" +fault.py "GET /api/2.0/test/echo" 503 0 1 +MSYS_NO_PATHCONV=1 trace $CLI api get /api/2.0/test/echo +trace print_requests.py --get //test/echo --del-field headers diff --git a/acceptance/cmd/api/errors/test.toml b/acceptance/cmd/api/errors/test.toml new file mode 100644 index 00000000000..1130ff940b3 --- /dev/null +++ b/acceptance/cmd/api/errors/test.toml @@ -0,0 +1,21 @@ +# Error responses in the shapes the platform returns them; the 404 is shared +# with the debug test and lives in the parent test.toml. +[[Server]] +Pattern = "GET /api/2.0/test/err400" +Response.StatusCode = 400 +Response.Body = '{"error_code": "INVALID_PARAMETER_VALUE", "message": "Cluster abc does not exist", "details": [{"@type": "type.googleapis.com/google.rpc.RequestInfo", "request_id": "req-1", "serving_data": ""}]}' + +[[Server]] +Pattern = "GET /api/2.0/test/err403" +Response.StatusCode = 403 +Response.Body = 'Forbidden' + +[[Server]] +Pattern = "GET /api/2.0/test/err500" +Response.StatusCode = 500 +Response.Body = 'Internal Server Error' + +[[Server]] +Pattern = "POST /api/2.0/test/err409" +Response.StatusCode = 409 +Response.Body = '{"error_code": "RESOURCE_CONFLICT", "message": "Branch exists"}' diff --git a/acceptance/cmd/api/flags/out.test.toml b/acceptance/cmd/api/flags/out.test.toml new file mode 100644 index 00000000000..18b1a88417e --- /dev/null +++ b/acceptance/cmd/api/flags/out.test.toml @@ -0,0 +1 @@ +Cloud = false diff --git a/acceptance/cmd/api/flags/output.txt b/acceptance/cmd/api/flags/output.txt new file mode 100644 index 00000000000..94fa40749f7 --- /dev/null +++ b/acceptance/cmd/api/flags/output.txt @@ -0,0 +1,78 @@ + +=== --account and --workspace-id are mutually exclusive +Error: --account and --workspace-id are mutually exclusive + +=== --workspace-id requires a value +Error: --workspace-id requires a value; use --account to scope this call to the account API + +=== PATH is required +Error: accepts 1 arg(s), received 0 + +Usage: + databricks api get PATH [flags] + +Flags: + --account[=true|false] Treat this call as account-scoped (skip the workspace routing identifier). Mutually exclusive with --workspace-id. + -h, --help[=true|false] help for get + --json JSON either inline JSON string or @path/to/file.json with request body (default JSON (0 bytes)) + --workspace-id string Override the workspace routing identifier on this call. Mutually exclusive with --account. + +Global Flags: + --debug[=true|false] enable debug logging + -o, --output type output type: text or json (default text) + -p, --profile string ~/.databrickscfg profile + -t, --target string bundle target to use (if applicable) + + +=== An unknown method prints the help and succeeds + +>>> [CLI] api options /api/2.0/test/echo +Perform Databricks API call + +Usage: + databricks api [command] + +Available Commands: + delete Perform DELETE request + get Perform GET request + head Perform HEAD request + patch Perform PATCH request + post Perform POST request + put Perform PUT request + +Flags: + -h, --help[=true|false] help for api + +Global Flags: + --debug[=true|false] enable debug logging + -o, --output type output type: text or json (default text) + -p, --profile string ~/.databrickscfg profile + -t, --target string bundle target to use (if applicable) + +Use "databricks api [command] --help" for more information about a command. + +=== curl-style flags are not accepted +Error: unknown shorthand flag: 'H' in -H +Error: unknown flag: --data +Error: unknown flag: --query +Error: unknown shorthand flag: 'i' in -i + +=== Help + +>>> [CLI] api get --help +Perform GET request + +Usage: + databricks api get PATH [flags] + +Flags: + --account[=true|false] Treat this call as account-scoped (skip the workspace routing identifier). Mutually exclusive with --workspace-id. + -h, --help[=true|false] help for get + --json JSON either inline JSON string or @path/to/file.json with request body (default JSON (0 bytes)) + --workspace-id string Override the workspace routing identifier on this call. Mutually exclusive with --account. + +Global Flags: + --debug[=true|false] enable debug logging + -o, --output type output type: text or json (default text) + -p, --profile string ~/.databrickscfg profile + -t, --target string bundle target to use (if applicable) diff --git a/acceptance/cmd/api/flags/script b/acceptance/cmd/api/flags/script new file mode 100644 index 00000000000..c7cfab225f7 --- /dev/null +++ b/acceptance/cmd/api/flags/script @@ -0,0 +1,23 @@ +# Flag validation and the flags that do not exist (curl-style flags). + +title "--account and --workspace-id are mutually exclusive" +MSYS_NO_PATHCONV=1 musterr $CLI api get /api/2.0/test/echo --account --workspace-id 1 + +title "--workspace-id requires a value" +MSYS_NO_PATHCONV=1 musterr $CLI api get /api/2.0/test/echo --workspace-id "" + +title "PATH is required" +musterr $CLI api get + +title "An unknown method prints the help and succeeds" +MSYS_NO_PATHCONV=1 trace $CLI api options /api/2.0/test/echo + +# Only the first line; the rest is the usage text pinned under "Help". +title "curl-style flags are not accepted" +MSYS_NO_PATHCONV=1 musterr $CLI api get /api/2.0/test/echo -H "X-Foo: bar" 2>&1 | head -n 1 +MSYS_NO_PATHCONV=1 musterr $CLI api post /api/2.0/test/echo --data '{"a": 1}' 2>&1 | head -n 1 +MSYS_NO_PATHCONV=1 musterr $CLI api get /api/2.0/test/echo --query a=b 2>&1 | head -n 1 +MSYS_NO_PATHCONV=1 musterr $CLI api get /api/2.0/test/echo -i 2>&1 | head -n 1 + +title "Help" +trace $CLI api get --help diff --git a/acceptance/cmd/api/json/body.json b/acceptance/cmd/api/json/body.json new file mode 100644 index 00000000000..a420e872ddf --- /dev/null +++ b/acceptance/cmd/api/json/body.json @@ -0,0 +1 @@ +{"name": "from-file", "tags": ["x", "y"], "nested": {"k": true}} diff --git a/acceptance/cmd/api/json/output.txt b/acceptance/cmd/api/json/output.txt index 467db6038ec..c7eab12d29e 100644 --- a/acceptance/cmd/api/json/output.txt +++ b/acceptance/cmd/api/json/output.txt @@ -28,3 +28,103 @@ OK: Accept header present === Malformed --json is rejected client-side with a positioned error Error: error decoding JSON at (inline):1:8: invalid character ',' looking for beginning of value + +=== --json @file is the body of a POST + +>>> [CLI] api post /api/2.0/test/echo --json @body.json +{ + "ok": true +} + +>>> print_requests.py //test/echo --del-field headers +{ + "method": "POST", + "path": "/api/2.0/test/echo", + "body": { + "name": "from-file", + "tags": [ + "x", + "y" + ], + "nested": { + "k": true + } + } +} + +=== --json @file on a GET is serialized into the query string, arrays and objects with Go's %v + +>>> [CLI] api get /api/2.0/test/echo --json @body.json +{ + "ok": true +} + +>>> print_requests.py --get //test/echo --del-field headers +{ + "method": "GET", + "path": "/api/2.0/test/echo", + "q": { + "name": "from-file", + "nested": "map[k:true]", + "tags": "[x y]" + } +} + +=== --json @- is not stdin; it is read as a file named '-' + +OK: '-' was opened as a file + +=== --json on a GET whose path already has a query string + +>>> [CLI] api get /api/2.0/test/echo?a=1 --json {"b": 2} +{ + "ok": true +} + +>>> print_requests.py --get //test/echo --del-field headers +{ + "method": "GET", + "path": "/api/2.0/test/echo", + "q": { + "a": "1?b=2" + } +} + +=== --json scalars on a GET: null is dropped, other zero values are kept + +>>> [CLI] api get /api/2.0/test/echo --json {"flag": true, "off": false, "n": 0, "empty": "", "none": null} +{ + "ok": true +} + +>>> print_requests.py --get //test/echo --del-field headers +{ + "method": "GET", + "path": "/api/2.0/test/echo", + "q": { + "empty": "", + "flag": "true", + "n": "0", + "off": "false" + } +} + +=== --json that is not an object is sent verbatim on a POST + +>>> [CLI] api post /api/2.0/test/echo --json [1, 2] +{ + "ok": true +} + +>>> print_requests.py //test/echo --del-field headers +{ + "method": "POST", + "path": "/api/2.0/test/echo", + "body": [ + 1, + 2 + ] +} + +=== --json that is not an object is rejected on a GET +Error: request marshal: unsupported query string data: []interface {}{"1", "2"} diff --git a/acceptance/cmd/api/json/script b/acceptance/cmd/api/json/script index f9efdb0396c..16558bfad24 100644 --- a/acceptance/cmd/api/json/script +++ b/acceptance/cmd/api/json/script @@ -15,3 +15,31 @@ trace print_requests.py //test/req --del-field headers title "Malformed --json is rejected client-side with a positioned error" MSYS_NO_PATHCONV=1 musterr $CLI api post /api/2.0/test/req --json '{"a": 1,}' + +title "--json @file is the body of a POST" +MSYS_NO_PATHCONV=1 trace $CLI api post /api/2.0/test/echo --json @body.json +trace print_requests.py //test/echo --del-field headers + +title "--json @file on a GET is serialized into the query string, arrays and objects with Go's %v" +MSYS_NO_PATHCONV=1 trace $CLI api get /api/2.0/test/echo --json @body.json +trace print_requests.py --get //test/echo --del-field headers + +title "--json @- is not stdin; it is read as a file named '-'" +echo '{"a": 1}' | MSYS_NO_PATHCONV=1 musterr $CLI api post /api/2.0/test/echo --json @- &> LOG.stdin +contains.py "open -" < LOG.stdin > /dev/null +printf '\n%s\n' "OK: '-' was opened as a file" + +title "--json on a GET whose path already has a query string" +MSYS_NO_PATHCONV=1 trace $CLI api get "/api/2.0/test/echo?a=1" --json '{"b": 2}' +trace print_requests.py --get //test/echo --del-field headers + +title "--json scalars on a GET: null is dropped, other zero values are kept" +MSYS_NO_PATHCONV=1 trace $CLI api get /api/2.0/test/echo --json '{"flag": true, "off": false, "n": 0, "empty": "", "none": null}' +trace print_requests.py --get //test/echo --del-field headers + +title "--json that is not an object is sent verbatim on a POST" +MSYS_NO_PATHCONV=1 trace $CLI api post /api/2.0/test/echo --json '[1, 2]' +trace print_requests.py //test/echo --del-field headers + +title "--json that is not an object is rejected on a GET" +MSYS_NO_PATHCONV=1 musterr $CLI api get /api/2.0/test/echo --json '[1, 2]' diff --git a/acceptance/cmd/api/methods/out.test.toml b/acceptance/cmd/api/methods/out.test.toml new file mode 100644 index 00000000000..18b1a88417e --- /dev/null +++ b/acceptance/cmd/api/methods/out.test.toml @@ -0,0 +1 @@ +Cloud = false diff --git a/acceptance/cmd/api/methods/output.txt b/acceptance/cmd/api/methods/output.txt new file mode 100644 index 00000000000..9301bed1d24 --- /dev/null +++ b/acceptance/cmd/api/methods/output.txt @@ -0,0 +1,380 @@ + +=== get without --json + +>>> [CLI] api get /api/2.0/test/echo +{ + "ok": true +} + +>>> print_requests.py --get //test/echo +{ + "headers": { + "Accept": [ + "application/json" + ], + "Authorization": [ + "Bearer [DATABRICKS_TOKEN]" + ], + "Content-Type": [ + "application/json" + ], + "User-Agent": [ + "cli/[CLI_VERSION] databricks-sdk-go/[SDK_VERSION] go/[GO_VERSION] os/[OS] cmd/api_get cmd-exec-id/[UUID][0] interactive/none auth/pat" + ], + "X-Databricks-Workspace-Id": [ + "[WORKSPACE_ID]" + ] + }, + "method": "GET", + "path": "/api/2.0/test/echo" +} + +=== get with --json + +>>> [CLI] api get /api/2.0/test/echo --json {"id": 7, "name": "a b"} +{ + "ok": true +} + +>>> print_requests.py --get //test/echo +{ + "headers": { + "Accept": [ + "application/json" + ], + "Authorization": [ + "Bearer [DATABRICKS_TOKEN]" + ], + "Content-Type": [ + "application/json" + ], + "User-Agent": [ + "cli/[CLI_VERSION] databricks-sdk-go/[SDK_VERSION] go/[GO_VERSION] os/[OS] cmd/api_get cmd-exec-id/[UUID][1] interactive/none auth/pat" + ], + "X-Databricks-Workspace-Id": [ + "[WORKSPACE_ID]" + ] + }, + "method": "GET", + "path": "/api/2.0/test/echo", + "q": { + "id": "7", + "name": "a b" + } +} + +=== head without --json + +>>> [CLI] api head /api/2.0/test/echo +null + +>>> print_requests.py --get //test/echo +{ + "headers": { + "Accept": [ + "application/json" + ], + "Authorization": [ + "Bearer [DATABRICKS_TOKEN]" + ], + "Content-Type": [ + "application/json" + ], + "User-Agent": [ + "cli/[CLI_VERSION] databricks-sdk-go/[SDK_VERSION] go/[GO_VERSION] os/[OS] cmd/api_head cmd-exec-id/[UUID][2] interactive/none auth/pat" + ], + "X-Databricks-Workspace-Id": [ + "[WORKSPACE_ID]" + ] + }, + "method": "HEAD", + "path": "/api/2.0/test/echo" +} + +=== head with --json + +>>> [CLI] api head /api/2.0/test/echo --json {"id": 7, "name": "a b"} +null + +>>> print_requests.py --get //test/echo +{ + "headers": { + "Accept": [ + "application/json" + ], + "Authorization": [ + "Bearer [DATABRICKS_TOKEN]" + ], + "Content-Type": [ + "application/json" + ], + "User-Agent": [ + "cli/[CLI_VERSION] databricks-sdk-go/[SDK_VERSION] go/[GO_VERSION] os/[OS] cmd/api_head cmd-exec-id/[UUID][3] interactive/none auth/pat" + ], + "X-Databricks-Workspace-Id": [ + "[WORKSPACE_ID]" + ] + }, + "method": "HEAD", + "path": "/api/2.0/test/echo", + "q": { + "id": "7", + "name": "a b" + } +} + +=== post without --json + +>>> [CLI] api post /api/2.0/test/echo +{ + "ok": true +} + +>>> print_requests.py --get //test/echo +{ + "headers": { + "Accept": [ + "application/json" + ], + "Authorization": [ + "Bearer [DATABRICKS_TOKEN]" + ], + "Content-Type": [ + "application/json" + ], + "User-Agent": [ + "cli/[CLI_VERSION] databricks-sdk-go/[SDK_VERSION] go/[GO_VERSION] os/[OS] cmd/api_post cmd-exec-id/[UUID][4] interactive/none auth/pat" + ], + "X-Databricks-Workspace-Id": [ + "[WORKSPACE_ID]" + ] + }, + "method": "POST", + "path": "/api/2.0/test/echo" +} + +=== post with --json + +>>> [CLI] api post /api/2.0/test/echo --json {"id": 7, "name": "a b"} +{ + "ok": true +} + +>>> print_requests.py --get //test/echo +{ + "headers": { + "Accept": [ + "application/json" + ], + "Authorization": [ + "Bearer [DATABRICKS_TOKEN]" + ], + "Content-Type": [ + "application/json" + ], + "User-Agent": [ + "cli/[CLI_VERSION] databricks-sdk-go/[SDK_VERSION] go/[GO_VERSION] os/[OS] cmd/api_post cmd-exec-id/[UUID][5] interactive/none auth/pat" + ], + "X-Databricks-Workspace-Id": [ + "[WORKSPACE_ID]" + ] + }, + "method": "POST", + "path": "/api/2.0/test/echo", + "body": { + "id": 7, + "name": "a b" + } +} + +=== put without --json + +>>> [CLI] api put /api/2.0/test/echo +{ + "ok": true +} + +>>> print_requests.py --get //test/echo +{ + "headers": { + "Accept": [ + "application/json" + ], + "Authorization": [ + "Bearer [DATABRICKS_TOKEN]" + ], + "Content-Type": [ + "application/json" + ], + "User-Agent": [ + "cli/[CLI_VERSION] databricks-sdk-go/[SDK_VERSION] go/[GO_VERSION] os/[OS] cmd/api_put cmd-exec-id/[UUID][6] interactive/none auth/pat" + ], + "X-Databricks-Workspace-Id": [ + "[WORKSPACE_ID]" + ] + }, + "method": "PUT", + "path": "/api/2.0/test/echo" +} + +=== put with --json + +>>> [CLI] api put /api/2.0/test/echo --json {"id": 7, "name": "a b"} +{ + "ok": true +} + +>>> print_requests.py --get //test/echo +{ + "headers": { + "Accept": [ + "application/json" + ], + "Authorization": [ + "Bearer [DATABRICKS_TOKEN]" + ], + "Content-Type": [ + "application/json" + ], + "User-Agent": [ + "cli/[CLI_VERSION] databricks-sdk-go/[SDK_VERSION] go/[GO_VERSION] os/[OS] cmd/api_put cmd-exec-id/[UUID][7] interactive/none auth/pat" + ], + "X-Databricks-Workspace-Id": [ + "[WORKSPACE_ID]" + ] + }, + "method": "PUT", + "path": "/api/2.0/test/echo", + "body": { + "id": 7, + "name": "a b" + } +} + +=== patch without --json + +>>> [CLI] api patch /api/2.0/test/echo +{ + "ok": true +} + +>>> print_requests.py --get //test/echo +{ + "headers": { + "Accept": [ + "application/json" + ], + "Authorization": [ + "Bearer [DATABRICKS_TOKEN]" + ], + "Content-Type": [ + "application/json" + ], + "User-Agent": [ + "cli/[CLI_VERSION] databricks-sdk-go/[SDK_VERSION] go/[GO_VERSION] os/[OS] cmd/api_patch cmd-exec-id/[UUID][8] interactive/none auth/pat" + ], + "X-Databricks-Workspace-Id": [ + "[WORKSPACE_ID]" + ] + }, + "method": "PATCH", + "path": "/api/2.0/test/echo" +} + +=== patch with --json + +>>> [CLI] api patch /api/2.0/test/echo --json {"id": 7, "name": "a b"} +{ + "ok": true +} + +>>> print_requests.py --get //test/echo +{ + "headers": { + "Accept": [ + "application/json" + ], + "Authorization": [ + "Bearer [DATABRICKS_TOKEN]" + ], + "Content-Type": [ + "application/json" + ], + "User-Agent": [ + "cli/[CLI_VERSION] databricks-sdk-go/[SDK_VERSION] go/[GO_VERSION] os/[OS] cmd/api_patch cmd-exec-id/[UUID][9] interactive/none auth/pat" + ], + "X-Databricks-Workspace-Id": [ + "[WORKSPACE_ID]" + ] + }, + "method": "PATCH", + "path": "/api/2.0/test/echo", + "body": { + "id": 7, + "name": "a b" + } +} + +=== delete without --json + +>>> [CLI] api delete /api/2.0/test/echo +{ + "ok": true +} + +>>> print_requests.py --get //test/echo +{ + "headers": { + "Accept": [ + "application/json" + ], + "Authorization": [ + "Bearer [DATABRICKS_TOKEN]" + ], + "Content-Type": [ + "application/json" + ], + "User-Agent": [ + "cli/[CLI_VERSION] databricks-sdk-go/[SDK_VERSION] go/[GO_VERSION] os/[OS] cmd/api_delete cmd-exec-id/[UUID][10] interactive/none auth/pat" + ], + "X-Databricks-Workspace-Id": [ + "[WORKSPACE_ID]" + ] + }, + "method": "DELETE", + "path": "/api/2.0/test/echo" +} + +=== delete with --json + +>>> [CLI] api delete /api/2.0/test/echo --json {"id": 7, "name": "a b"} +{ + "ok": true +} + +>>> print_requests.py --get //test/echo +{ + "headers": { + "Accept": [ + "application/json" + ], + "Authorization": [ + "Bearer [DATABRICKS_TOKEN]" + ], + "Content-Type": [ + "application/json" + ], + "User-Agent": [ + "cli/[CLI_VERSION] databricks-sdk-go/[SDK_VERSION] go/[GO_VERSION] os/[OS] cmd/api_delete cmd-exec-id/[UUID][11] interactive/none auth/pat" + ], + "X-Databricks-Workspace-Id": [ + "[WORKSPACE_ID]" + ] + }, + "method": "DELETE", + "path": "/api/2.0/test/echo", + "q": { + "id": "7", + "name": "a b" + } +} diff --git a/acceptance/cmd/api/methods/script b/acceptance/cmd/api/methods/script new file mode 100644 index 00000000000..36c97cadd10 --- /dev/null +++ b/acceptance/cmd/api/methods/script @@ -0,0 +1,13 @@ +# One request per HTTP method, with and without --json. Pins where the JSON +# input goes (query string for GET, HEAD and DELETE; body otherwise) and which +# headers are sent. + +for method in get head post put patch delete; do + title "$method without --json" + MSYS_NO_PATHCONV=1 trace $CLI api $method /api/2.0/test/echo + trace print_requests.py --get //test/echo + + title "$method with --json" + MSYS_NO_PATHCONV=1 trace $CLI api $method /api/2.0/test/echo --json '{"id": 7, "name": "a b"}' + trace print_requests.py --get //test/echo +done diff --git a/acceptance/cmd/api/methods/test.toml b/acceptance/cmd/api/methods/test.toml new file mode 100644 index 00000000000..efda25e31ba --- /dev/null +++ b/acceptance/cmd/api/methods/test.toml @@ -0,0 +1,3 @@ +# Appended to the inherited list so the recorded requests show how the request +# is described, not only how it is authenticated and routed. +IncludeRequestHeaders = ["Accept", "Content-Type"] diff --git a/acceptance/cmd/api/response-handling/output.txt b/acceptance/cmd/api/response-handling/output.txt deleted file mode 100644 index 11719fed44b..00000000000 --- a/acceptance/cmd/api/response-handling/output.txt +++ /dev/null @@ -1,20 +0,0 @@ - -=== Empty response body renders null - ->>> [CLI] api get /api/2.0/test/empty -null - -=== A trailing newline in the body does not add a blank line - ->>> [CLI] api get /api/2.0/test/trailing -{ - "ok": true -} - -=== An HTML response surfaces the SDK's actionable error - -OK: HTML detected - -=== A malformed JSON response surfaces an unmarshal error - -OK: unmarshal error reported diff --git a/acceptance/cmd/api/response-handling/test.toml b/acceptance/cmd/api/response-handling/test.toml deleted file mode 100644 index 8689303a8a7..00000000000 --- a/acceptance/cmd/api/response-handling/test.toml +++ /dev/null @@ -1,18 +0,0 @@ -# Fixtures for the response-rendering edge cases. The HTML and malformed bodies -# must surface the SDK's errors (the *json.RawMessage target keeps that -# handling); the trailing newline must not produce a blank line. -[[Server]] -Pattern = "GET /api/2.0/test/empty" -Response.Body = '' - -[[Server]] -Pattern = "GET /api/2.0/test/trailing" -Response.Body = "{\"ok\": true}\n" - -[[Server]] -Pattern = "GET /api/2.0/test/html" -Response.Body = 'DatabricksSign in' - -[[Server]] -Pattern = "GET /api/2.0/test/malformed" -Response.Body = '{"truncated":' diff --git a/acceptance/cmd/api/response-json/out.test.toml b/acceptance/cmd/api/response-json/out.test.toml new file mode 100644 index 00000000000..18b1a88417e --- /dev/null +++ b/acceptance/cmd/api/response-json/out.test.toml @@ -0,0 +1 @@ +Cloud = false diff --git a/acceptance/cmd/api/response-json/output.txt b/acceptance/cmd/api/response-json/output.txt new file mode 100644 index 00000000000..68b3a7c6d27 --- /dev/null +++ b/acceptance/cmd/api/response-json/output.txt @@ -0,0 +1,72 @@ + +=== Empty response body renders null + +>>> [CLI] api get /api/2.0/test/empty +null + +=== A trailing newline in the body does not add a blank line + +>>> [CLI] api get /api/2.0/test/trailing +{ + "ok": true +} + +=== JSON object + +>>> [CLI] api get /api/2.0/test/echo +{ + "ok": true +} + +=== JSON object with -o text + +>>> [CLI] api get /api/2.0/test/echo -o text +{ + "ok": true +} + +=== JSON array + +>>> [CLI] api get /api/2.0/test/array +[ + { + "id": 1 + }, + { + "id": 2 + } +] + +=== JSON string + +>>> [CLI] api get /api/2.0/test/string +"hello" + +=== JSON number + +>>> [CLI] api get /api/2.0/test/number +42 + +=== JSON null + +>>> [CLI] api get /api/2.0/test/null +null + +=== 201 with a body + +>>> [CLI] api get /api/2.0/test/created +{ + "id": 1 +} + +=== 204 without a body renders null + +>>> [CLI] api get /api/2.0/test/nocontent +null + +=== JSON body with a text/plain content type is rendered + +>>> [CLI] api get /api/2.0/test/json-as-text +{ + "ok": true +} diff --git a/acceptance/cmd/api/response-json/script b/acceptance/cmd/api/response-json/script new file mode 100644 index 00000000000..f1dec34b4fb --- /dev/null +++ b/acceptance/cmd/api/response-json/script @@ -0,0 +1,34 @@ +# How a JSON response body is rendered. + +title "Empty response body renders null" +MSYS_NO_PATHCONV=1 trace $CLI api get /api/2.0/test/empty + +title "A trailing newline in the body does not add a blank line" +MSYS_NO_PATHCONV=1 trace $CLI api get /api/2.0/test/trailing + +title "JSON object" +MSYS_NO_PATHCONV=1 trace $CLI api get /api/2.0/test/echo + +title "JSON object with -o text" +MSYS_NO_PATHCONV=1 trace $CLI api get /api/2.0/test/echo -o text + +title "JSON array" +MSYS_NO_PATHCONV=1 trace $CLI api get /api/2.0/test/array + +title "JSON string" +MSYS_NO_PATHCONV=1 trace $CLI api get /api/2.0/test/string + +title "JSON number" +MSYS_NO_PATHCONV=1 trace $CLI api get /api/2.0/test/number + +title "JSON null" +MSYS_NO_PATHCONV=1 trace $CLI api get /api/2.0/test/null + +title "201 with a body" +MSYS_NO_PATHCONV=1 trace $CLI api get /api/2.0/test/created + +title "204 without a body renders null" +MSYS_NO_PATHCONV=1 trace $CLI api get /api/2.0/test/nocontent + +title "JSON body with a text/plain content type is rendered" +MSYS_NO_PATHCONV=1 trace $CLI api get /api/2.0/test/json-as-text diff --git a/acceptance/cmd/api/response-json/test.toml b/acceptance/cmd/api/response-json/test.toml new file mode 100644 index 00000000000..dbfead42d00 --- /dev/null +++ b/acceptance/cmd/api/response-json/test.toml @@ -0,0 +1,39 @@ +# The trailing newline must not produce a blank line; 204 has no body. +[[Server]] +Pattern = "GET /api/2.0/test/empty" +Response.Body = '' + +[[Server]] +Pattern = "GET /api/2.0/test/trailing" +Response.Body = "{\"ok\": true}\n" + +[[Server]] +Pattern = "GET /api/2.0/test/array" +Response.Body = '[{"id": 1}, {"id": 2}]' + +[[Server]] +Pattern = "GET /api/2.0/test/string" +Response.Body = '"hello"' + +[[Server]] +Pattern = "GET /api/2.0/test/number" +Response.Body = '42' + +[[Server]] +Pattern = "GET /api/2.0/test/null" +Response.Body = 'null' + +[[Server]] +Pattern = "GET /api/2.0/test/created" +Response.StatusCode = 201 +Response.Body = '{"id": 1}' + +[[Server]] +Pattern = "GET /api/2.0/test/nocontent" +Response.StatusCode = 204 +Response.Body = '' + +[[Server]] +Pattern = "GET /api/2.0/test/json-as-text" +Response.Body = '{"ok": true}' +Response.Headers = { "Content-Type" = ["text/plain"] } diff --git a/acceptance/cmd/api/response-text/out.test.toml b/acceptance/cmd/api/response-text/out.test.toml new file mode 100644 index 00000000000..18b1a88417e --- /dev/null +++ b/acceptance/cmd/api/response-text/out.test.toml @@ -0,0 +1 @@ +Cloud = false diff --git a/acceptance/cmd/api/response-text/output.txt b/acceptance/cmd/api/response-text/output.txt new file mode 100644 index 00000000000..476f9231422 --- /dev/null +++ b/acceptance/cmd/api/response-text/output.txt @@ -0,0 +1,14 @@ + +=== An HTML response surfaces the SDK's actionable error + +OK: HTML detected + +=== A malformed JSON response surfaces an unmarshal error + +OK: unmarshal error reported + +=== A CSV body is an error +Error: failed to unmarshal response body: invalid character 'a' looking for beginning of value. This is likely a bug in the Databricks SDK for Go or the underlying REST API. Please report this issue with the following debugging information to the SDK issue tracker at https://github.com/databricks/databricks-sdk-go/issues. Request log: + +=== An event stream is an error +Error: failed to unmarshal response body: invalid character 'd' looking for beginning of value. This is likely a bug in the Databricks SDK for Go or the underlying REST API. Please report this issue with the following debugging information to the SDK issue tracker at https://github.com/databricks/databricks-sdk-go/issues. Request log: diff --git a/acceptance/cmd/api/response-handling/script b/acceptance/cmd/api/response-text/script similarity index 54% rename from acceptance/cmd/api/response-handling/script rename to acceptance/cmd/api/response-text/script index 0b60491a35c..fa4c30ad4fb 100644 --- a/acceptance/cmd/api/response-handling/script +++ b/acceptance/cmd/api/response-text/script @@ -1,12 +1,6 @@ -# Response-rendering edge cases. The errors are routed to LOG files (their -# detail includes volatile request/response dumps); contains.py asserts the -# stable part. - -title "Empty response body renders null" -MSYS_NO_PATHCONV=1 trace $CLI api get /api/2.0/test/empty - -title "A trailing newline in the body does not add a blank line" -MSYS_NO_PATHCONV=1 trace $CLI api get /api/2.0/test/trailing +# Response bodies that are not JSON. The HTML and malformed errors are routed to +# LOG files because their detail includes volatile request/response dumps; for +# the other errors only the first line is stable. title "An HTML response surfaces the SDK's actionable error" MSYS_NO_PATHCONV=1 musterr $CLI api get /api/2.0/test/html &> LOG.html @@ -17,3 +11,9 @@ title "A malformed JSON response surfaces an unmarshal error" MSYS_NO_PATHCONV=1 musterr $CLI api get /api/2.0/test/malformed &> LOG.malformed contains.py "failed to unmarshal response body" < LOG.malformed > /dev/null printf '\n%s\n' "OK: unmarshal error reported" + +title "A CSV body is an error" +MSYS_NO_PATHCONV=1 musterr $CLI api get /api/2.0/test/csv 2>&1 | head -n 1 + +title "An event stream is an error" +MSYS_NO_PATHCONV=1 musterr $CLI api get /api/2.0/test/event-stream 2>&1 | head -n 1 diff --git a/acceptance/cmd/api/response-text/test.toml b/acceptance/cmd/api/response-text/test.toml new file mode 100644 index 00000000000..20e4f410141 --- /dev/null +++ b/acceptance/cmd/api/response-text/test.toml @@ -0,0 +1,17 @@ +# The HTML and malformed bodies must surface the SDK's errors. +[[Server]] +Pattern = "GET /api/2.0/test/html" +Response.Body = 'DatabricksSign in' + +[[Server]] +Pattern = "GET /api/2.0/test/malformed" +Response.Body = '{"truncated":' + +[[Server]] +Pattern = "GET /api/2.0/test/csv" +Response.Body = "a,b\n1,2\n" + +[[Server]] +Pattern = "GET /api/2.0/test/event-stream" +Response.Body = "data: {\"n\": 1}\n\ndata: {\"n\": 2}\n\n" +Response.Headers = { "Content-Type" = ["text/event-stream"] } diff --git a/acceptance/cmd/api/test.toml b/acceptance/cmd/api/test.toml index d1a9112ed0e..6921606c7db 100644 --- a/acceptance/cmd/api/test.toml +++ b/acceptance/cmd/api/test.toml @@ -38,3 +38,33 @@ Response.Body = '{}' [[Server]] Pattern = "GET /api/2.0/preview/accounts/access-control/rule-sets" Response.Body = '{}' + +# /api/2.0/test/echo accepts every method; tests assert on the recorded request. +[[Server]] +Pattern = "GET /api/2.0/test/echo" +Response.Body = '{"ok": true}' + +[[Server]] +Pattern = "HEAD /api/2.0/test/echo" +Response.Body = '{"ok": true}' + +[[Server]] +Pattern = "POST /api/2.0/test/echo" +Response.Body = '{"ok": true}' + +[[Server]] +Pattern = "PUT /api/2.0/test/echo" +Response.Body = '{"ok": true}' + +[[Server]] +Pattern = "PATCH /api/2.0/test/echo" +Response.Body = '{"ok": true}' + +[[Server]] +Pattern = "DELETE /api/2.0/test/echo" +Response.Body = '{"ok": true}' + +[[Server]] +Pattern = "GET /api/2.0/test/err404" +Response.StatusCode = 404 +Response.Body = '{"error_code": "RESOURCE_DOES_NOT_EXIST", "message": "Not found"}' diff --git a/acceptance/cmd/api/url/out.test.toml b/acceptance/cmd/api/url/out.test.toml new file mode 100644 index 00000000000..18b1a88417e --- /dev/null +++ b/acceptance/cmd/api/url/out.test.toml @@ -0,0 +1 @@ +Cloud = false diff --git a/acceptance/cmd/api/url/output.txt b/acceptance/cmd/api/url/output.txt new file mode 100644 index 00000000000..e1b18f64098 --- /dev/null +++ b/acceptance/cmd/api/url/output.txt @@ -0,0 +1,52 @@ + +=== An absolute URL is sent to the configured host; only its path and query are used + +>>> [CLI] api get https://other.test/api/2.0/test/echo?from=url +{ + "ok": true +} + +>>> print_requests.py --get //test/echo --del-field headers +{ + "method": "GET", + "path": "/api/2.0/test/echo", + "q": { + "from": "url" + } +} + +=== Percent-encoded characters in the query are preserved + +>>> [CLI] api get /api/2.0/test/echo?name=a%20b&path=%2Fx +{ + "ok": true +} + +>>> print_requests.py --get //test/echo --del-field headers +{ + "method": "GET", + "path": "/api/2.0/test/echo", + "q": { + "name": "a b", + "path": "/x" + } +} + +=== A fragment is not sent + +>>> [CLI] api get /api/2.0/test/echo?x=1#frag +{ + "ok": true +} + +>>> print_requests.py --get //test/echo --del-field headers +{ + "method": "GET", + "path": "/api/2.0/test/echo", + "q": { + "x": "1" + } +} + +=== A path without a leading slash is rejected by the server +Error: 400 Bad Request diff --git a/acceptance/cmd/api/url/script b/acceptance/cmd/api/url/script new file mode 100644 index 00000000000..3862843068f --- /dev/null +++ b/acceptance/cmd/api/url/script @@ -0,0 +1,16 @@ +# How the PATH argument is turned into a URL. + +title "An absolute URL is sent to the configured host; only its path and query are used" +MSYS_NO_PATHCONV=1 trace $CLI api get "https://other.test/api/2.0/test/echo?from=url" +trace print_requests.py --get //test/echo --del-field headers + +title "Percent-encoded characters in the query are preserved" +MSYS_NO_PATHCONV=1 trace $CLI api get "/api/2.0/test/echo?name=a%20b&path=%2Fx" +trace print_requests.py --get //test/echo --del-field headers + +title "A fragment is not sent" +MSYS_NO_PATHCONV=1 trace $CLI api get "/api/2.0/test/echo?x=1#frag" +trace print_requests.py --get //test/echo --del-field headers + +title "A path without a leading slash is rejected by the server" +musterr $CLI api get api/2.0/test/echo From cd0327b1b5d628c4346cc95a90c14a7cbee8c30c Mon Sep 17 00:00:00 2001 From: "pieter.noordhuis" Date: Mon, 30 Nov 2026 11:06:58 +0000 Subject: [PATCH 3/3] acceptance: make the api goldens catch what they are named for Review follow-ups. The JSON fixtures set Content-Type explicitly: a string body gets no header from the test server and net/http sniffs it as text/plain, so the text/plain case was no contrast. The percent-encoding case is retitled to what the decoded recording can show. The debug golden keeps only the request and response dump; the CLI lifecycle, local cache, resolved config and telemetry lines go to the test log, and the host-metadata cache is warmed so the discovery exchange does not appear in the first case only. Co-authored-by: Isaac --- acceptance/cmd/api/debug/output.txt | 31 ---------------------- acceptance/cmd/api/debug/script | 9 +++++-- acceptance/cmd/api/debug/test.toml | 9 +++++++ acceptance/cmd/api/errors/test.toml | 2 ++ acceptance/cmd/api/response-json/test.toml | 6 +++++ acceptance/cmd/api/test.toml | 9 +++++++ acceptance/cmd/api/url/output.txt | 2 +- acceptance/cmd/api/url/script | 5 +++- 8 files changed, 38 insertions(+), 35 deletions(-) diff --git a/acceptance/cmd/api/debug/output.txt b/acceptance/cmd/api/debug/output.txt index cb92d70e14c..8f822fb8785 100644 --- a/acceptance/cmd/api/debug/output.txt +++ b/acceptance/cmd/api/debug/output.txt @@ -2,19 +2,6 @@ === GET with --json >>> [CLI] api get /api/2.0/test/echo --json {"id": 7} --debug -HH:MM:SS Info: start pid=PID version=[CLI_VERSION] args="[CLI], api, get, /api/2.0/test/echo, --json, {\"id\": 7}, --debug" -HH:MM:SS Debug: [Local Cache] using cache key: [SHA256_HASH] pid=PID -HH:MM:SS Debug: [Local Cache] cache miss, computing pid=PID -HH:MM:SS Debug: GET /.well-known/databricks-config -< HTTP/1.1 200 OK -< { -< "oidc_endpoint": "[DATABRICKS_URL]/oidc", -< "workspace_id": "[WORKSPACE_ID]" -< } pid=PID sdk=true -HH:MM:SS Debug: [Local Cache] computed and stored result pid=PID -HH:MM:SS Debug: Resolved workspace_id from host metadata: "[WORKSPACE_ID]" pid=PID sdk=true -HH:MM:SS Debug: Resolved cloud from hostname: "AWS" pid=PID sdk=true -HH:MM:SS Debug: Resolved discovery_url from host metadata: "[DATABRICKS_URL]/oidc/.well-known/oauth-authorization-server" pid=PID sdk=true HH:MM:SS Debug: GET /api/2.0/test/echo?id=7 < HTTP/1.1 200 OK < { @@ -23,18 +10,10 @@ HH:MM:SS Debug: GET /api/2.0/test/echo?id=7 { "ok": true } -HH:MM:SS Info: completed execution pid=PID exit_code=0 -HH:MM:SS Debug: no telemetry logs to upload pid=PID === POST with --json >>> [CLI] api post /api/2.0/test/echo --json {"id": 7} --debug -HH:MM:SS Info: start pid=PID version=[CLI_VERSION] args="[CLI], api, post, /api/2.0/test/echo, --json, {\"id\": 7}, --debug" -HH:MM:SS Debug: [Local Cache] using cache key: [SHA256_HASH] pid=PID -HH:MM:SS Debug: [Local Cache] cache hit pid=PID -HH:MM:SS Debug: Resolved workspace_id from host metadata: "[WORKSPACE_ID]" pid=PID sdk=true -HH:MM:SS Debug: Resolved cloud from hostname: "AWS" pid=PID sdk=true -HH:MM:SS Debug: Resolved discovery_url from host metadata: "[DATABRICKS_URL]/oidc/.well-known/oauth-authorization-server" pid=PID sdk=true HH:MM:SS Debug: POST /api/2.0/test/echo > { > "id": 7 @@ -46,16 +25,8 @@ HH:MM:SS Debug: POST /api/2.0/test/echo { "ok": true } -HH:MM:SS Info: completed execution pid=PID exit_code=0 -HH:MM:SS Debug: no telemetry logs to upload pid=PID === Error response -HH:MM:SS Info: start pid=PID version=[CLI_VERSION] args="[CLI], api, get, /api/2.0/test/err404, --debug" -HH:MM:SS Debug: [Local Cache] using cache key: [SHA256_HASH] pid=PID -HH:MM:SS Debug: [Local Cache] cache hit pid=PID -HH:MM:SS Debug: Resolved workspace_id from host metadata: "[WORKSPACE_ID]" pid=PID sdk=true -HH:MM:SS Debug: Resolved cloud from hostname: "AWS" pid=PID sdk=true -HH:MM:SS Debug: Resolved discovery_url from host metadata: "[DATABRICKS_URL]/oidc/.well-known/oauth-authorization-server" pid=PID sdk=true HH:MM:SS Debug: GET /api/2.0/test/err404 < HTTP/1.1 404 Not Found < { @@ -64,5 +35,3 @@ HH:MM:SS Debug: GET /api/2.0/test/err404 < } pid=PID sdk=true HH:MM:SS Debug: non-retriable error: Not found pid=PID sdk=true Error: Not found -HH:MM:SS Info: failed execution pid=PID exit_code=1 error="Not found" -HH:MM:SS Debug: no telemetry logs to upload pid=PID diff --git a/acceptance/cmd/api/debug/script b/acceptance/cmd/api/debug/script index db9914ab8ef..22245d11858 100644 --- a/acceptance/cmd/api/debug/script +++ b/acceptance/cmd/api/debug/script @@ -1,5 +1,10 @@ -# What --debug prints for a request: the resolved configuration, the outgoing -# request and the response, including bodies. +# What --debug prints for a request: the outgoing request and the response, +# including bodies. The lines around the dump are moved to the test log (see +# test.toml). + +# Warm the host-metadata cache so the /.well-known/databricks-config exchange +# does not show up in the first case only. +MSYS_NO_PATHCONV=1 $CLI api get /api/2.0/test/echo > /dev/null title "GET with --json" MSYS_NO_PATHCONV=1 trace $CLI api get /api/2.0/test/echo --json '{"id": 7}' --debug 2>&1 diff --git a/acceptance/cmd/api/debug/test.toml b/acceptance/cmd/api/debug/test.toml index dbcec41e41e..d6cc6b36f6e 100644 --- a/acceptance/cmd/api/debug/test.toml +++ b/acceptance/cmd/api/debug/test.toml @@ -1,3 +1,12 @@ +# Only the request and response dump is about `databricks api`; the lines the +# CLI root and the SDK log around it (start/completed, local cache, resolved +# config, telemetry) are moved to the test log so an SDK bump that rewords them +# does not fail this test. +SuppressLines.debug_cli_lifecycle = '^HH:MM:SS Info: (start|completed execution|failed execution) ' +SuppressLines.debug_local_cache = '^HH:MM:SS Debug: \[Local Cache\] ' +SuppressLines.debug_resolved_config = '^HH:MM:SS Debug: Resolved \w+ from ' +SuppressLines.debug_telemetry = '^HH:MM:SS Debug: no telemetry logs to upload' + # --debug output carries the process id, wall-clock timestamps and the # host-metadata cache key, which hashes the test server URL (random port). [[Repls]] diff --git a/acceptance/cmd/api/errors/test.toml b/acceptance/cmd/api/errors/test.toml index 1130ff940b3..2fed8b709b4 100644 --- a/acceptance/cmd/api/errors/test.toml +++ b/acceptance/cmd/api/errors/test.toml @@ -4,6 +4,7 @@ Pattern = "GET /api/2.0/test/err400" Response.StatusCode = 400 Response.Body = '{"error_code": "INVALID_PARAMETER_VALUE", "message": "Cluster abc does not exist", "details": [{"@type": "type.googleapis.com/google.rpc.RequestInfo", "request_id": "req-1", "serving_data": ""}]}' +Response.Headers = { "Content-Type" = ["application/json"] } [[Server]] Pattern = "GET /api/2.0/test/err403" @@ -19,3 +20,4 @@ Response.Body = 'Internal Server Error' Pattern = "POST /api/2.0/test/err409" Response.StatusCode = 409 Response.Body = '{"error_code": "RESOURCE_CONFLICT", "message": "Branch exists"}' +Response.Headers = { "Content-Type" = ["application/json"] } diff --git a/acceptance/cmd/api/response-json/test.toml b/acceptance/cmd/api/response-json/test.toml index dbfead42d00..b6f2e040979 100644 --- a/acceptance/cmd/api/response-json/test.toml +++ b/acceptance/cmd/api/response-json/test.toml @@ -6,27 +6,33 @@ Response.Body = '' [[Server]] Pattern = "GET /api/2.0/test/trailing" Response.Body = "{\"ok\": true}\n" +Response.Headers = { "Content-Type" = ["application/json"] } [[Server]] Pattern = "GET /api/2.0/test/array" Response.Body = '[{"id": 1}, {"id": 2}]' +Response.Headers = { "Content-Type" = ["application/json"] } [[Server]] Pattern = "GET /api/2.0/test/string" Response.Body = '"hello"' +Response.Headers = { "Content-Type" = ["application/json"] } [[Server]] Pattern = "GET /api/2.0/test/number" Response.Body = '42' +Response.Headers = { "Content-Type" = ["application/json"] } [[Server]] Pattern = "GET /api/2.0/test/null" Response.Body = 'null' +Response.Headers = { "Content-Type" = ["application/json"] } [[Server]] Pattern = "GET /api/2.0/test/created" Response.StatusCode = 201 Response.Body = '{"id": 1}' +Response.Headers = { "Content-Type" = ["application/json"] } [[Server]] Pattern = "GET /api/2.0/test/nocontent" diff --git a/acceptance/cmd/api/test.toml b/acceptance/cmd/api/test.toml index 6921606c7db..70da9c9e8ed 100644 --- a/acceptance/cmd/api/test.toml +++ b/acceptance/cmd/api/test.toml @@ -40,31 +40,40 @@ Pattern = "GET /api/2.0/preview/accounts/access-control/rule-sets" Response.Body = '{}' # /api/2.0/test/echo accepts every method; tests assert on the recorded request. +# A string body gets no Content-Type from the test server (net/http sniffs it as +# text/plain), so the JSON fixtures set it explicitly. [[Server]] Pattern = "GET /api/2.0/test/echo" Response.Body = '{"ok": true}' +Response.Headers = { "Content-Type" = ["application/json"] } [[Server]] Pattern = "HEAD /api/2.0/test/echo" Response.Body = '{"ok": true}' +Response.Headers = { "Content-Type" = ["application/json"] } [[Server]] Pattern = "POST /api/2.0/test/echo" Response.Body = '{"ok": true}' +Response.Headers = { "Content-Type" = ["application/json"] } [[Server]] Pattern = "PUT /api/2.0/test/echo" Response.Body = '{"ok": true}' +Response.Headers = { "Content-Type" = ["application/json"] } [[Server]] Pattern = "PATCH /api/2.0/test/echo" Response.Body = '{"ok": true}' +Response.Headers = { "Content-Type" = ["application/json"] } [[Server]] Pattern = "DELETE /api/2.0/test/echo" Response.Body = '{"ok": true}' +Response.Headers = { "Content-Type" = ["application/json"] } [[Server]] Pattern = "GET /api/2.0/test/err404" Response.StatusCode = 404 Response.Body = '{"error_code": "RESOURCE_DOES_NOT_EXIST", "message": "Not found"}' +Response.Headers = { "Content-Type" = ["application/json"] } diff --git a/acceptance/cmd/api/url/output.txt b/acceptance/cmd/api/url/output.txt index e1b18f64098..b8bce6e02eb 100644 --- a/acceptance/cmd/api/url/output.txt +++ b/acceptance/cmd/api/url/output.txt @@ -15,7 +15,7 @@ } } -=== Percent-encoded characters in the query are preserved +=== Percent-encoded characters in the query are decoded once by the server >>> [CLI] api get /api/2.0/test/echo?name=a%20b&path=%2Fx { diff --git a/acceptance/cmd/api/url/script b/acceptance/cmd/api/url/script index 3862843068f..ee017c2741b 100644 --- a/acceptance/cmd/api/url/script +++ b/acceptance/cmd/api/url/script @@ -4,7 +4,10 @@ title "An absolute URL is sent to the configured host; only its path and query a MSYS_NO_PATHCONV=1 trace $CLI api get "https://other.test/api/2.0/test/echo?from=url" trace print_requests.py --get //test/echo --del-field headers -title "Percent-encoded characters in the query are preserved" +# The recorder stores the decoded query, so this pins that escapes are decoded +# exactly once (a double-encoded %2520 would show up as "a%20b"), not the +# encoding on the wire. +title "Percent-encoded characters in the query are decoded once by the server" MSYS_NO_PATHCONV=1 trace $CLI api get "/api/2.0/test/echo?name=a%20b&path=%2Fx" trace print_requests.py --get //test/echo --del-field headers