Skip to content

Add text output mode for auth token and auth env#4725

Open
simonfaltum wants to merge 7 commits intomainfrom
simonfaltum/auth-text-output
Open

Add text output mode for auth token and auth env#4725
simonfaltum wants to merge 7 commits intomainfrom
simonfaltum/auth-text-output

Conversation

@simonfaltum
Copy link
Member

@simonfaltum simonfaltum commented Mar 12, 2026

Why

databricks auth token and databricks auth env always output JSON, ignoring the --output flag. Users who want to pipe the token string or source env vars have to parse JSON first.

Changes

Before: Both commands always output JSON regardless of the --output flag.
Now: Both commands respect --output text when explicitly set:

  • auth token --output text: outputs just the access token string, suitable for piping
  • auth env --output text: outputs KEY=VALUE lines, compatible with .env loaders and eval

JSON remains the default (backward compatible). Text mode activates only when the user explicitly passes --output text.

Test plan

  • Unit tests for both commands in text and JSON modes
  • Unit test for backward compatibility (no explicit --output keeps JSON)
  • Unit test for value quoting in auth env text mode
  • make checks passes

Both commands now respect --output text when explicitly set:
- auth token --output text: outputs just the access token string
- auth env --output text: outputs KEY=VALUE lines

JSON remains the default for backward compatibility.

Co-authored-by: Isaac
@eng-dev-ecosystem-bot
Copy link
Collaborator

eng-dev-ecosystem-bot commented Mar 12, 2026

Commit: a6000ec

Run: 23057119600

Env 💥​PANIC ❌​FAIL 🟨​KNOWN 🤯​MISS 🔄​flaky 💚​RECOVERED 🙈​SKIP ✅​pass 🙈​skip Time
🔄​ aws linux 2 6 7 268 787 13:11
💚​ aws windows 8 7 270 785 10:36
💥​ aws-ucws linux 1 4 1 11 7 7 347 702 132:07
❌​ aws-ucws windows 1 2 7 7 363 700 25:46
🔄​ azure linux 1 2 9 270 785 12:29
💚​ azure windows 2 9 273 783 10:05
❌​ azure-ucws linux 1 4 1 9 364 698 28:04
❌​ azure-ucws windows 3 4 1 9 366 696 26:05
🔄​ gcp linux 2 9 267 788 10:54
💚​ gcp windows 2 9 269 786 9:53
38 interesting tests: 11 MISS, 7 SKIP, 6 FAIL, 6 flaky, 6 RECOVERED, 1 KNOWN, 1 PANIC
Test Name aws linux aws windows aws-ucws linux aws-ucws windows azure linux azure windows azure-ucws linux azure-ucws windows gcp linux gcp windows
🟨​ TestAccept 🔄​f 💚​R 🟨​K 🔄​f 💚​R 💚​R 💚​R 💚​R 🔄​f 💚​R
❌​ TestAccept/bundle/generate/auto-bind ✅​p ✅​p ❌​F ✅​p ✅​p ✅​p ✅​p ✅​p ✅​p ✅​p
🔄​ TestAccept/bundle/resources/model_serving_endpoints/basic 🙈​s 🙈​s ✅​p ✅​p 🙈​s 🙈​s 🔄​f ✅​p 🙈​s 🙈​s
🔄​ TestAccept/bundle/resources/model_serving_endpoints/basic/DATABRICKS_BUNDLE_ENGINE=direct ✅​p ✅​p 🔄​f ✅​p
🙈​ TestAccept/bundle/resources/permissions 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🔄​ TestAccept/bundle/resources/permissions/dashboards/create ✅​p ✅​p ✅​p ✅​p ✅​p ✅​p ✅​p 🔄​f 🙈​s 🙈​s
🔄​ TestAccept/bundle/resources/permissions/dashboards/create/DATABRICKS_BUNDLE_ENGINE=terraform ✅​p ✅​p ✅​p ✅​p ✅​p ✅​p ✅​p 🔄​f
❌​ TestAccept/bundle/resources/permissions/jobs/delete_one/cloud 🙈​s 🙈​s ❌​F ✅​p 🙈​s 🙈​s ✅​p ✅​p 🙈​s 🙈​s
❌​ TestAccept/bundle/resources/permissions/jobs/delete_one/cloud/DATABRICKS_BUNDLE_ENGINE=direct ❌​F ✅​p ✅​p ✅​p
💚​ TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/with_permissions 💚​R 💚​R 💚​R 💚​R 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
💚​ TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/with_permissions/DATABRICKS_BUNDLE_ENGINE=direct 💚​R 💚​R 💚​R 💚​R
💚​ TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/with_permissions/DATABRICKS_BUNDLE_ENGINE=terraform 💚​R 💚​R 💚​R 💚​R
💚​ TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/without_permissions 💚​R 💚​R 💚​R 💚​R 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
💚​ TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/without_permissions/DATABRICKS_BUNDLE_ENGINE=direct 💚​R 💚​R 💚​R 💚​R
💚​ TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/without_permissions/DATABRICKS_BUNDLE_ENGINE=terraform 💚​R 💚​R 💚​R 💚​R
🙈​ TestAccept/bundle/resources/postgres_branches/basic 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/postgres_branches/recreate 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/postgres_branches/update_protected 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/postgres_branches/without_branch_id 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/postgres_endpoints/recreate 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/synced_database_tables/basic 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🔄​ TestAccept/ssh/connect-serverless-gpu 🙈​s 🙈​s ✅​p 🔄​f 🙈​s 🙈​s ✅​p 🔄​f 🙈​s 🙈​s
🔄​ TestAccept/ssh/connection 🔄​f 💚​R 💚​R 💚​R 💚​R 💚​R 🔄​f 🔄​f 🔄​f 💚​R
🤯​ TestSyncEnsureRemotePathIsUsableIfRepoDoesntExist ✅​p ✅​p 🤯​M ✅​p ✅​p ✅​p ✅​p ✅​p ✅​p ✅​p
🤯​ TestSyncEnsureRemotePathIsUsableIfRepoExists ✅​p ✅​p 🤯​M ✅​p ✅​p ✅​p ✅​p ✅​p ✅​p ✅​p
🤯​ TestSyncEnsureRemotePathIsUsableInWorkspace ✅​p ✅​p 🤯​M ✅​p ✅​p ✅​p ✅​p ✅​p ✅​p ✅​p
💥​ TestSyncFullFileSync ✅​p ✅​p 💥​P ✅​p ✅​p ✅​p 🔄​f ✅​p ✅​p ✅​p
🤯​ TestSyncIncrementalFileOverwritesFolder ✅​p ✅​p 🤯​M ✅​p ✅​p ✅​p ✅​p ✅​p ✅​p ✅​p
🤯​ TestSyncIncrementalFileSync ✅​p ✅​p 🤯​M ✅​p ✅​p ✅​p ✅​p ✅​p ✅​p ✅​p
🤯​ TestSyncIncrementalSyncFileToPythonNotebook ✅​p ✅​p 🤯​M ✅​p ✅​p ✅​p ✅​p ✅​p ✅​p ✅​p
🤯​ TestSyncIncrementalSyncPythonNotebookDelete ✅​p ✅​p 🤯​M ✅​p ✅​p ✅​p ✅​p ✅​p ✅​p ✅​p
🤯​ TestSyncIncrementalSyncPythonNotebookToFile ✅​p ✅​p 🤯​M ✅​p ✅​p ✅​p ✅​p ✅​p ✅​p ✅​p
🤯​ TestSyncNestedFolderDoesntFailOnNonEmptyDirectory ✅​p ✅​p 🤯​M ✅​p ✅​p ✅​p ✅​p ✅​p ✅​p ✅​p
🤯​ TestSyncNestedFolderSync ✅​p ✅​p 🤯​M ✅​p ✅​p ✅​p ✅​p ✅​p ✅​p ✅​p
🤯​ TestSyncNestedSpacePlusAndHashAreEscapedSync ✅​p ✅​p 🤯​M ✅​p ✅​p ✅​p ✅​p ✅​p ✅​p ✅​p
❌​ TestFetchRepositoryInfoAPI_FromRepo ✅​p ✅​p ❌​F ❌​F 🔄​f ✅​p ❌​F ❌​F ✅​p ✅​p
❌​ TestFetchRepositoryInfoAPI_FromRepo//Workspace/Repos/a71e69be-fe57-484b-ae8b-bb6ce382668a/integration-test-0acc76a91a674fab9f7c389399eb4f47 ❌​F
❌​ TestFetchRepositoryInfoAPI_FromRepo//Workspace/Repos/a71e69be-fe57-484b-ae8b-bb6ce382668a/integration-test-0acc76a91a674fab9f7c389399eb4f47/knowledge_base/dashboard_nyc_taxi ❌​F
Top 50 slowest tests (at least 2 minutes):
duration env testname
7:35 azure-ucws windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
6:53 azure-ucws linux TestAccept/bundle/resources/volumes/recreate/DATABRICKS_BUNDLE_ENGINE=direct
5:56 aws-ucws linux TestAccept/bundle/resources/volumes/recreate/DATABRICKS_BUNDLE_ENGINE=terraform
5:47 aws-ucws linux TestAccept/bundle/deployment/bind/job/generate-and-bind/DATABRICKS_BUNDLE_ENGINE=direct
5:36 azure-ucws windows TestAccept/bundle/deploy/files/no-snapshot-sync/DATABRICKS_BUNDLE_ENGINE=direct
5:31 aws-ucws windows TestAccept/bundle/deploy/files/no-snapshot-sync/DATABRICKS_BUNDLE_ENGINE=terraform
5:07 azure-ucws linux TestAccept/bundle/resources/volumes/recreate/DATABRICKS_BUNDLE_ENGINE=terraform
4:57 aws-ucws windows TestAccept/bundle/deployment/bind/job/generate-and-bind/DATABRICKS_BUNDLE_ENGINE=terraform
4:56 aws windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
4:53 aws-ucws linux TestAccept/bundle/resources/volumes/recreate/DATABRICKS_BUNDLE_ENGINE=direct
4:48 aws-ucws windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
4:47 aws windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
4:44 aws-ucws linux TestAccept/bundle/deploy/files/no-snapshot-sync/DATABRICKS_BUNDLE_ENGINE=direct
4:43 aws-ucws linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
4:37 aws-ucws windows TestAccept/bundle/deployment/bind/job/generate-and-bind/DATABRICKS_BUNDLE_ENGINE=direct
4:30 gcp linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
4:10 aws-ucws windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
4:02 gcp windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
3:59 azure-ucws linux TestAccept/ssh/connect-serverless-gpu
3:46 aws-ucws windows TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/without_permissions/DATABRICKS_BUNDLE_ENGINE=direct
3:43 aws-ucws linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
3:38 aws-ucws windows TestAccept/bundle/destroy/jobs-and-pipeline/DATABRICKS_BUNDLE_ENGINE=terraform
3:37 gcp windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
3:34 azure-ucws windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
3:32 azure-ucws linux TestAccept/bundle/resources/jobs/shared-root-path/DATABRICKS_BUNDLE_ENGINE=terraform
3:31 aws linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
3:29 azure-ucws windows TestAccept/bundle/resources/model_serving_endpoints/basic/DATABRICKS_BUNDLE_ENGINE=direct
3:28 azure-ucws linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
3:27 gcp linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
3:21 aws-ucws windows TestAccept/bundle/resources/permissions/jobs/delete_one/cloud/DATABRICKS_BUNDLE_ENGINE=terraform
3:20 azure-ucws linux TestAccept/bundle/resources/jobs/shared-root-path/DATABRICKS_BUNDLE_ENGINE=direct
3:12 azure-ucws linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
3:06 azure-ucws linux TestAccept/bundle/resources/jobs/check-metadata/DATABRICKS_BUNDLE_ENGINE=direct
3:04 azure-ucws windows TestAccept/bundle/deploy/files/no-snapshot-sync/DATABRICKS_BUNDLE_ENGINE=terraform
3:03 azure-ucws linux TestAccept/bundle/deployment/bind/job/generate-and-bind/DATABRICKS_BUNDLE_ENGINE=direct
3:03 aws-ucws windows TestLock
3:01 aws linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
3:00 aws-ucws windows TestAccept/bundle/resources/model_serving_endpoints/basic/DATABRICKS_BUNDLE_ENGINE=terraform
2:58 aws-ucws windows TestAccept/bundle/resources/volumes/recreate/DATABRICKS_BUNDLE_ENGINE=direct
2:58 aws-ucws linux TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/without_permissions/DATABRICKS_BUNDLE_ENGINE=direct
2:55 azure linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
2:53 azure windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
2:52 azure linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
2:49 azure-ucws windows TestSparkJarTaskDeployAndRunOnWorkspace/Databricks_Runtime_14.3_LTS
2:48 azure-ucws linux TestFilerWorkspaceFilesExtensionsDelete
2:47 azure-ucws windows TestAccept/bundle/resources/dashboards/generate_inplace/DATABRICKS_BUNDLE_ENGINE=terraform
2:43 azure-ucws linux TestAccept/bundle/deploy/files/no-snapshot-sync/DATABRICKS_BUNDLE_ENGINE=direct
2:42 aws-ucws windows TestAccept/bundle/deploy/files/no-snapshot-sync/DATABRICKS_BUNDLE_ENGINE=direct
2:41 azure-ucws windows TestAccept/bundle/deployment/bind/job/generate-and-bind/DATABRICKS_BUNDLE_ENGINE=terraform
2:38 aws-ucws linux TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/without_permissions/DATABRICKS_BUNDLE_ENGINE=terraform

@simonfaltum simonfaltum marked this pull request as ready for review March 13, 2026 10:59
Copy link
Contributor

@shreyas-goenka shreyas-goenka left a comment

Choose a reason for hiding this comment

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

Note: This review was posted by Claude (AI assistant). Shreyas will do a separate, more thorough review pass.

Priority: MEDIUM — Env var inconsistency needs a decision

HIGH: DATABRICKS_OUTPUT_FORMAT env var silently ignored

Both auth token and auth env commands use cmd.Flag("output").Changed to detect text mode, which means the DATABRICKS_OUTPUT_FORMAT=text env var is ignored. This is inconsistent with the rest of the CLI where the env var is a first-class way to set output format. The guard exists because these commands have an inverted default (JSON by default, unlike other commands), so without it the default behavior would break. A decision is needed on whether the env var should be honored here.

MEDIUM: Shell quoting not fully .env-file compatible

The quoteEnvValue function uses POSIX shell single-quote escaping ('\''), but the PR description claims ".env loader" compatibility. Most .env parsers (Docker, python-dotenv) use different quoting rules. Only eval usage is truly compatible.

LOW: Doc comment typo

quoteEnvValue doc references '\" but code does '\''.

What looks good

  • Backward compatibility preserved (JSON remains default)
  • collectEnvVars extraction reduces duplication
  • Clean text output formatting

The comment referenced the '\" escape sequence, but the code
actually uses the POSIX '\'' sequence (end-quote, backslash-escaped
literal single quote, re-open quote).
…al characters

Values containing \n or \r were emitted unquoted, producing raw multi-line
shell output instead of a single safe KEY=VALUE pair. Add both characters
to shellQuotedSpecialChars so they trigger single-quoting.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants