Skip to content

Strip trailing slash from host in auth and configure commands - #4633

Merged
simonfaltum merged 3 commits into
databricks:mainfrom
varundeepsaini:fix-auto-strip-backslash-auth-host
Mar 12, 2026
Merged

Strip trailing slash from host in auth and configure commands#4633
simonfaltum merged 3 commits into
databricks:mainfrom
varundeepsaini:fix-auto-strip-backslash-auth-host

Conversation

@varundeepsaini

Copy link
Copy Markdown
Contributor

Fixes#4628

Summary

  • Strip trailing slash from host URL in setHostAndAccountId (used by auth login and auth token)
  • Strip trailing slash in normalizeHost (used by databricks configure)

Test plan

  • Added test cases for trailing slash stripping in setHostAndAccountId (flag and positional arg)
  • Updated normalizeHost test expectations for trailing slash inputs
  • Verified all existing tests pass

simonfaltum
simonfaltum previously approved these changes Mar 3, 2026

@simonfaltumsimonfaltum left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@simonfaltum
simonfaltum dismissed their stale reviewMarch 3, 2026 11:53

Just taking another look

@simonfaltumsimonfaltum left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Had an extra look. Would you be up for adding some tests for the auth token path?
The setHostAndAccountId function is also called from cmd/auth/token.go:166 and token.go:426

Comment threadcmd/auth/login.go Outdated
// Strip trailing slash from host. Users often copy-paste URLs with a
// trailing slash from browsers or docs; normalize here to avoid errors
// from downstream validation in the SDK.
authArguments.Host = strings.TrimRight(authArguments.Host, "/")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Using strings.TrimRight(input, "/"), which strips all trailing / characters from the right side of the string, character by character. I think this is subtly wrong for edge cases.

Look at the test expectation on line 32 of host_test.go: {"https://", "https:"},

TrimRight("https://", "/") strips both trailing slashes from https://, producing "https:". That's clearly broken. The input https:// is an invalid host either way, but the function is now actively mangling it in a confusing way. I think the correct function to use is strings.TrimSuffix(input, "/") which only removes a single trailing /.

For https://example.com/ both functions produce the same result, but TrimRight is a future trap for multi-slash paths or edge cases, I think?

Comment threadcmd/configure/host.go Outdated
Comment threadcmd/configure/host.go Outdated
@varundeepsaini
varundeepsainiforce-pushed the fix-auto-strip-backslash-auth-host branch from 16c3003 to 00ed36cCompareMarch 3, 2026 12:47
@varundeepsaini
varundeepsainiforce-pushed the fix-auto-strip-backslash-auth-host branch 2 times, most recently from dfd5ed1 to 81f2d25CompareMarch 3, 2026 12:51
Signed-off-by: Varun Deep Saini <varun.23bcs10048@ms.sst.scaler.com>
@varundeepsaini
varundeepsainiforce-pushed the fix-auto-strip-backslash-auth-host branch from 81f2d25 to 5db8392CompareMarch 3, 2026 12:58

@simonfaltumsimonfaltum left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks Varun! LGTM

@varundeepsaini

varundeepsaini commented Mar 3, 2026

Copy link
Copy Markdown
ContributorAuthor

@simonfaltum could you run the ci ?

@github-actions

Copy link
Copy Markdown
Contributor

An authorized user can trigger integration tests manually by following the instructions below:

Trigger:
go/deco-tests-run/cli

Inputs:

  • PR number: 4633
  • Commit SHA: 5149e4611294a209290a64bdd3fbf9fa1cb92796

Checks will be approved automatically on success.

@eng-dev-ecosystem-bot

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

Copy link
Copy Markdown
Collaborator

Commit: 5149e46

Run: 22900526692

Env🟨​KNOWN🔄​flaky💚​RECOVERED🙈​SKIP✅​pass🙈​skipTime
🟨​aws linux7172687816:10
🟨​aws windows7172707796:36
🔄​aws-ucws linux2773646966:50
🔄​aws-ucws windows2773666946:41
💚​azure linux292717794:38
💚​azure windows292737774:17
🔄​azure-ucws linux2193696927:52
🔄​azure-ucws windows2193716906:54
💚​gcp linux292677826:27
💚​gcp windows292697805:13
16 interesting tests: 7 KNOWN, 7 SKIP, 2 flaky
Test Nameaws linuxaws windowsaws-ucws linuxaws-ucws windowsazure linuxazure windowsazure-ucws linuxazure-ucws windowsgcp linuxgcp windows
🟨​TestAccept🟨​K🟨​K💚​R🔄​f💚​R💚​R🔄​f🔄​f💚​R💚​R
🙈​TestAccept/bundle/resources/permissions🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S
🟨​TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/with_permissions🟨​K🟨​K💚​R💚​R🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S
🟨​TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/with_permissions/DATABRICKS_BUNDLE_ENGINE=direct🟨​K🟨​K💚​R💚​R
🟨​TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/with_permissions/DATABRICKS_BUNDLE_ENGINE=terraform🟨​K🟨​K💚​R💚​R
🟨​TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/without_permissions🟨​K🟨​K💚​R💚​R🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S
🟨​TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/without_permissions/DATABRICKS_BUNDLE_ENGINE=direct🟨​K🟨​K💚​R💚​R
🟨​TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/without_permissions/DATABRICKS_BUNDLE_ENGINE=terraform🟨​K🟨​K💚​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🔄​f🔄​f🙈​s🙈​s🔄​f🔄​f🙈​s🙈​s
🔄​TestAccept/ssh/connection💚​R💚​R🔄​f💚​R💚​R💚​R💚​R💚​R💚​R💚​R
Top 21 slowest tests (at least 2 minutes):
durationenvtestname
4:59azure-ucws windowsTestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
4:08gcp windowsTestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
4:01azure-ucws linuxTestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
3:59aws-ucws linuxTestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
3:55aws-ucws windowsTestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
3:50aws windowsTestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
3:50aws-ucws windowsTestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
3:44aws-ucws linuxTestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
3:40gcp linuxTestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
3:22aws linuxTestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
3:17aws linuxTestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
3:13aws windowsTestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
3:12gcp linuxTestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
3:10gcp windowsTestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
2:18gcp linuxTestSecretsPutSecretStringValue
2:13azure windowsTestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
2:13azure linuxTestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
2:10azure windowsTestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
2:09azure-ucws linuxTestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
2:08azure linuxTestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
2:06azure-ucws windowsTestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct

@varundeepsaini

Copy link
Copy Markdown
ContributorAuthor

@andrewnester could we merge thiis ?

@simonfaltum
simonfaltum added this pull request to the merge queueMar 12, 2026
Merged via the queue into databricks:main with commit 309f527Mar 12, 2026
18 checks passed
@varundeepsaini
varundeepsaini deleted the fix-auto-strip-backslash-auth-host branch March 16, 2026 11:38
rauchy pushed a commit that referenced this pull request Mar 17, 2026
Fixes#4628
## Summary
- Strip trailing slash from host URL in `setHostAndAccountId` (used by
`auth login` and `auth token`)
- Strip trailing slash in `normalizeHost` (used by `databricks
configure`)
## Test plan
- [x] Added test cases for trailing slash stripping in
`setHostAndAccountId` (flag and positional arg)
- [x] Updated `normalizeHost` test expectations for trailing slash
inputs
- [x] Verified all existing tests pass
Signed-off-by: Varun Deep Saini <varun.23bcs10048@ms.sst.scaler.com>
Co-authored-by: simon <simon.faltum@databricks.com>
deco-sdk-taggingBot added a commit that referenced this pull request Mar 18, 2026
## Release v0.295.0
### Notable Changes
* Databricks Asset Bundles have been renamed to Declarative Automation Bundles (DABs). This is a non-breaking change; no code or configuration modifications are required. See the [FAQ](https://docs.databricks.com/aws/en/dev-tools/bundles/faqs#why-was-databricks-asset-bundles-renamed-to-declarative-automation-bundles).
* Add `bundle.engine` config setting to select the deployment engine (`terraform` or [`direct`](https://docs.databricks.com/aws/en/dev-tools/bundles/direct)). The `bundle.engine` setting takes precedence over the `DATABRICKS_BUNDLE_ENGINE` environment variable. When the configured engine doesn't match existing deployment state, a warning is issued and the existing engine is used ([#4749](#4749), [#4782](#4782))
### CLI
* Add `databricks auth switch` command for setting the default profile ([#4651](#4651))
* Add positional argument support to `auth logout` ([#4744](#4744))
* Strip trailing slash from host in `auth login`, `auth token`, and `configure` commands ([#4633](#4633))
### Bundles
* Standardize `personal_schemas` enum across bundle templates ([#4401](#4401))
* engine/direct: Fix permanent drift on experiment name field ([#4627](#4627))
* engine/direct: Fix permissions state path to match input config schema ([#4703](#4703))
* Add default project name and success message to default-scala template ([#4661](#4661))
* Skip enum validation for unresolved variable references ([#4752](#4752))
* engine/direct: Support references to/from grants ([#4774](#4774))
denik pushed a commit that referenced this pull request May 20, 2026
Fixes#4628
## Summary
- Strip trailing slash from host URL in `setHostAndAccountId` (used by
`auth login` and `auth token`)
- Strip trailing slash in `normalizeHost` (used by `databricks
configure`)
## Test plan
- [x] Added test cases for trailing slash stripping in
`setHostAndAccountId` (flag and positional arg)
- [x] Updated `normalizeHost` test expectations for trailing slash
inputs
- [x] Verified all existing tests pass
Signed-off-by: Varun Deep Saini <varun.23bcs10048@ms.sst.scaler.com>
Co-authored-by: simon <simon.faltum@databricks.com>
denik pushed a commit that referenced this pull request May 20, 2026
## Release v0.295.0
### Notable Changes
* Databricks Asset Bundles have been renamed to Declarative Automation Bundles (DABs). This is a non-breaking change; no code or configuration modifications are required. See the [FAQ](https://docs.databricks.com/aws/en/dev-tools/bundles/faqs#why-was-databricks-asset-bundles-renamed-to-declarative-automation-bundles).
* Add `bundle.engine` config setting to select the deployment engine (`terraform` or [`direct`](https://docs.databricks.com/aws/en/dev-tools/bundles/direct)). The `bundle.engine` setting takes precedence over the `DATABRICKS_BUNDLE_ENGINE` environment variable. When the configured engine doesn't match existing deployment state, a warning is issued and the existing engine is used ([#4749](#4749), [#4782](#4782))
### CLI
* Add `databricks auth switch` command for setting the default profile ([#4651](#4651))
* Add positional argument support to `auth logout` ([#4744](#4744))
* Strip trailing slash from host in `auth login`, `auth token`, and `configure` commands ([#4633](#4633))
### Bundles
* Standardize `personal_schemas` enum across bundle templates ([#4401](#4401))
* engine/direct: Fix permanent drift on experiment name field ([#4627](#4627))
* engine/direct: Fix permissions state path to match input config schema ([#4703](#4703))
* Add default project name and success message to default-scala template ([#4661](#4661))
* Skip enum validation for unresolved variable references ([#4752](#4752))
* engine/direct: Support references to/from grants ([#4774](#4774))
Sign up for freeto 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.

databricks auth login: strip trailing slash from host instead of erroring

4 participants

@varundeepsaini@eng-dev-ecosystem-bot@andrewnester@simonfaltum