Repository navigation
Split access tokens that don't fit in one OS keyring item - #7845
Conversation
databricks auth login failed on macOS and Windows with "store token: data passed to Set was too big" when the OAuth access token did not fit in one OS keyring item (#7707). The keyring store now splits such a token: the item under the cache key keeps the token without its access token, the part count and the access token's SHA-256, and the access token goes into 2048-byte parts under <key>#access-token-<n>. The item with the refresh token is written first. A missing or mismatched part returns the token without an access token, so that it is refreshed. Delete removes every part, and auth login rejects profile names that contain #access-token-. A token that fits is stored exactly as before. Co-authored-by: Isaac <no-reply@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
|
Commit: Regression test reportSelected 1 changed tests (limit=20, 0 not selected) 1 tests: regression=1 unreleased=0 coverage=0 failing=0
TestAccept/cmd/auth/login/device-code/non-interactive/errors: branch ✅ | main (36fdeb1) ❌ | latest (v1.27.0) ❌main (36fdeb1): latest (v1.27.0): same output as main (36fdeb1) |
✅ Integration test reportCommit: a83d3a7
Top 3 slowest tests (at least 2 minutes):
|
|
/review |
There was a problem hiding this comment.
Automated review at 6bc858e. Each finding was verified against the code.
No blocking issues found.
This PR adds multi-item keyring storage for OAuth access tokens that exceed OS keyring item size limits on macOS and Windows, fixing databricks auth login failures with store token: data passed to Set was too big. The implementation is careful: the refresh token is written first, a SHA-256 hash guards against torn reads, and tokens that fit in one item stay in the format older CLI versions understand. The code is well tested across both fake and real OS keyring backends, with coverage for size transitions, partial failures, and backward compatibility. No concrete defects were found.
Lookup reads a split entry again (25 ms doubling, 5 attempts) when its access token parts are missing or do not match, so a reader that catches another process writing or deleting the entry neither refreshes with a refresh token that process already used up nor restores a deleted login. Delete counts the parts and deletes them from the last, so a Delete that fails part way leaves parts that the next one still finds. A refresh whose part write fails still succeeds when the store kept the new refresh token: recoverStoreUpdate accepts that partial update, so losing the access token only costs the next command a refresh. auth login rejects #access-token- in any letter case, because Windows Credential Manager ignores case in credential names. On macOS, zalandoBackend rejects a secret that go-keyring is sure to reject without calling it, because go-keyring starts `security -i` before its size check and leaves the process unreaped. keyringEntry embeds a struct that Entry converts to and from again, so a field added to Entry cannot be dropped silently. Also: string slicing in putSplit, doc comments, the service name constant in the new tests, and the original wording of the comments from #7727 except where they became wrong. Co-authored-by: Isaac <no-reply@databricks.com>
The keyring store's Put now wraps a failed access token part write in storage.ErrAccessTokenNotStored, after the entry with the refresh token was stored. PersistentAuth.refresh treats that error as stored and logs it at debug level, instead of recoverStoreUpdate guessing the state from the store's contents, which also matched a Put that wrote nothing when the server does not rotate refresh tokens. recoverStoreUpdate is back to its original form. A split entry now keeps every Entry field, not only the token, so the compile-time Entry mirror holds for both layouts. The Store and Entry docs say what the keyring store does differently. Also: the macOS fd test runs first in its file and requires an equal count, with a named helper instead of a closure; doc comment and wording fixes. Co-authored-by: Isaac <no-reply@databricks.com>
Lookup now waits splitLookupDelay when the store sets no retry delay, so a keyring store built without one still gives a concurrent writer time to finish, and a test pins that schedule. auth login keeps failing on storage.ErrAccessTokenNotStored, unlike a refresh: a comment says why. The new debug line uses libs/log, validateLoginProfileName keeps its original sentence, and TestDarwinCommandTooBig uses require. Co-authored-by: Isaac <no-reply@databricks.com>
There was a problem hiding this comment.
Automated review at 8ba8b84. Each finding was verified against the code.
No blocking issues found. 2 non-blocking comment(s) below.
This PR splits oversized OAuth access tokens across multiple OS keyring items so that databricks auth login works on macOS and Windows when a token exceeds the single-item limit. The implementation is thorough: it stores the refresh token first for safety, verifies reassembled parts with SHA-256, retries on concurrent writes, and cleans up parts on delete. The test coverage is extensive across both fake and real backends. I found only minor style issues; no correctness bugs survived verification.
| // openFileCount returns the number of files this process has open. | ||
| func openFileCount(t *testing.T) int { | ||
| t.Helper() | ||
| entries, err := os.ReadDir("/dev/fd") |
There was a problem hiding this comment.
[nit] openFileCount reads /dev/fd, which doesn't exist on Windows, but this file's build constraint is darwin || windows. The sole caller skips on non-darwin, so nothing breaks today, but a future Windows test in this file that calls openFileCount would fail at runtime with no compile-time hint. Moving the function (and TestZalandoBackend_Set_RejectsLargeSecretWithoutSecurityProcess) into a //go:build darwin-only file would prevent that.
There was a problem hiding this comment.
Moved the test and openFileCount to keyring_darwin_test.go in a83d3a7, so the /dev/fd read only builds on macOS. That file still sorts before the one with TestKeyringSet_RejectsLargeSecret, so the test keeps running first.
| RefreshToken: "first", | ||
| Expiry: time.Now().Add(-time.Minute), | ||
| }}) | ||
| if err != nil { |
There was a problem hiding this comment.
[nit] This new file uses t.Fatalf/t.Errorf throughout (lines 52, 59, 80, 86, 90, 98, …) instead of require/assert, which the testing rule prescribes. The same applies to the new tests in persistent_auth_test.go (TestToken_RefreshesTokenWithoutAccessToken, TestToken_RefreshesWithRefreshTokenStoredByFailedStoreUpdate). The pre-existing code in persistent_auth_test.go uses the same bare-testing style, so this is locally consistent, but other new test files in this PR (logout_keyring_os_test.go, keyring_size_limit_os_test.go) already use testify. Worth aligning the new file at least, or not — your call.
There was a problem hiding this comment.
Switched the new file to require/assert in a83d3a7. I kept persistent_auth_test.go, including its two new tests, in the t.Fatalf style the rest of that file uses.
…2m keychain test openFileCount reads /dev/fd, which Windows lacks, so the test and its helper now live in keyring_darwin_test.go instead of a darwin || windows file. The new u2m real-keychain test uses require and assert like the other new tests. Co-authored-by: Isaac <no-reply@databricks.com>
## Release v1.28.0 ### CLI * Retry transient errors in `fs` commands: `fs cp` to a UC Volume from another Volume or DBFS (files up to 8 MiB) on HTTP 503, DBFS uploads when the upload stream is lost, and stat, read and list on UC Volumes on HTTP 500. ([#7607](#7607), [#7763](#7763), [#7839](#7839)) * `databricks auth profiles --skip-validate` now omits the `Valid` column instead of reporting `NO` for every profile. ([#7638](#7638)) * Fix Ctrl-C taking about 10 seconds to stop `databricks aitools install`, `update` or `uninstall` while it runs a coding agent's CLI, and retry reading an agent's config on Windows while the agent rewrites it. ([#7832](#7832), [#7870](#7870)) * Automatic installation of Databricks AI tools no longer asks in containers or installs for the first time without a terminal, no longer runs as root in another user's home, keeps newer skills you installed, no longer hints to install what it is about to install, and on Linux and macOS stops the calling script on Ctrl-C. ([#7828](#7828), [#7834](#7834), [#7874](#7874), [#7888](#7888), [#7890](#7890), [#7901](#7901)) * Wait before retrying a failed automatic install of Databricks AI tools, starting at 5 minutes and doubling after each failure, so a skills source or coding agent CLI that stays broken no longer slows down each of the next commands. ([#7900](#7900)) * `databricks aitools install` now cancels the agent picker on Esc. ([#7721](#7721)) * `databricks aitools uninstall --skills` now fails when its value names no skill instead of removing every skill, and `aitools update` and `uninstall` no longer prompt when a coding agent runs them; with skills in both scopes they fail and ask for `--scope`. ([#7873](#7873)) * `databricks aitools install --skills-only` and `databricks aitools update` no longer mix skill files with the Databricks plugin: install skips agents that already have the plugin, and update no longer replaces skill files from a `--skills-only` install made with this release or later while the agent's CLI was on PATH. To keep skill files from an earlier `--skills-only` install, run `databricks aitools install --skills-only` again with the agent's CLI on PATH. ([#7831](#7831), [#7903](#7903)) * `apps init` no longer suggests installing skills to Codex and Copilot users who installed the Databricks plugin with `databricks aitools install`. ([#7830](#7830)) * Fix `databricks auth login` failing with `data passed to Set was too big` on macOS and Windows for OAuth tokens too large for one keyring item. ([#7845](#7845)) * Fix the token storage mode (`auth_storage`) being read from the file named by `DATABRICKS_CONFIG_FILE` instead of the config file the profile was loaded from. ([#7733](#7733)) * `databricks auth login` no longer waits for the browser that the default opener starts to close before it continues. ([#7551](#7551)) * Allow `databricks auth docker configure` when several profiles match one workspace; the chosen profile is recorded for the registry and shown by `databricks auth docker host`. ([#7383](#7383)) * Show the HTTP status, error code and endpoint when an API error has no message, instead of a bare `Error: `, and the HTTP status and path for Files API errors that used to show an empty `databricks-api error:`. ([#7800](#7800), [#7839](#7839)) * AI agents can now submit feedback without confirmation; `--yes`/`-y` is deprecated, and agents passing `--yes=false` now get an error. ([#7795](#7795)) * Log `/.well-known/databricks-config` fetch failures with a transient HTTP status (408, 429, or 5xx other than 501) at debug level instead of as a warning, like timeouts. ([#7912](#7912)) * Fix interactive list output sometimes dropping or reordering a page of rows. ([#7804](#7804), [#7914](#7914)) * Allow `databricks sandbox forward` to forward remote ports below 10000. The sandbox refuses a few reserved platform ports with an error that names the port. ([#7861](#7861)) * Breaking: `databricks sandbox ssh` now uses local SSH keys and works with sandboxes created through the SDK or API; it no longer accepts `--port` and needs Python 3 and `openssh-server` in the sandbox. Add `databricks sandbox ssh-setup` to configure native SSH and SCP. ([#7588](#7588), [#7589](#7589), [#7590](#7590)) * `databricks ssh connect` to serverless CPU compute now defaults to environment version 5, so the first connection after upgrading starts a new server; pass `--environment-version 4` to keep the old one. ([#7847](#7847)) * `databricks ssh connect` now downloads the SSH server binaries from PyPI when GitHub is unreachable, using `PIP_INDEX_URL` or `index-url` from the per-user pip config over HTTPS only, and checks SHA-256 digests. ([#7852](#7852)) ### AI Runtime * Breaking: `compute.pool_id` is no longer accepted in AIR workload YAML; use `compute.accelerator_pool_id`. ([#7698](#7698)) * `databricks air convert-to-dabs` handles an existing output directory better: it gives the right guidance when the directory already holds the workload's bundle, `--force` no longer replaces a different bundle or an alternate root file, re-converting removes stale sidecars, and git-pinned code outside the bundle gets an `--output-dir` suggestion. ([#7835](#7835), [#7853](#7853), [#7857](#7857), [#7866](#7866)) * `air list` and `air get` now find the AI Runtime task anywhere in a multi-task job; a job with several such tasks lists one row per task (so `run_id` is no longer unique in `air list -o json`), and both report `task_key` (`air get --task-key` selects one). `air list --all-status` now orders runs by submission time instead of by their latest attempt's start. ([#7632](#7632)) * Update fallback messages for pending AI Runtime runs when AIR does not report a status reason. ([#7899](#7899)) * `air run -o json` now reports config-validation errors as a JSON error envelope, with `UNAUTHENTICATED`, `INVALID_ARGS` or the new `PERMISSION_DENIED` code. ([#7864](#7864)) ### Bundles * Bundle commands no longer hang after a request timeout on a dead HTTP/2 connection. ([#7723](#7723)) * Fix a panic when the local Terraform state is removed after it is pulled and before it is migrated to the direct engine, for example by a concurrent `bundle deploy`. ([#7778](#7778)) * The direct deployment engine now uses a Lakebase or postgres catalog that a failed create request still created, instead of failing the deploy. ([#7801](#7801)) * `bundle deploy` and `bundle run` for apps now succeed when the app's compute is already active or starting, and deploy the app when the deployment triggered by start failed. ([#7709](#7709), [#7780](#7780)) * Add `thumbnail_path` to the `apps` resource, so `bundle deploy` sets, updates and deletes the thumbnail shown for the app in the Apps UI. ([#7728](#7728)) * Fix bundle commands failing on a notebook or file path with a colon in its first segment, such as the default workspace notebook name `New Notebook 2026-10-28 12:17:43.ipynb`. ([#7851](#7851)) * `bundle run` and `pipelines run` now retry transient errors from the pipeline events and update status reads while waiting for an update. ([#7800](#7800)) ### Dependency Updates * Bump dependencies with known vulnerabilities. ([#7904](#7904)) * Update the Go SDK to [v0.203.0](https://github.com/databricks/databricks-sdk-go/releases/tag/v0.203.0). ([#7869](#7869), [#7906](#7906)) * Update `github.com/databricks/sdk-go/files` to [v0.9.0](https://github.com/databricks/sdk-go/blob/files/v0.9.0/files/CHANGELOG.md). ([#7889](#7889))
Changes
databricks auth loginfails on macOS and Windows withstore token: data passed to Set was too bigwhen the OAuth access token doesn't fit in one OS keyring item, and later commands then fail because the new refresh token was never stored. Fixes #7707. A token that doesn't fit is now stored across several items; a token that fits is stored exactly as before.<key>#access-token-<n>in the samedatabricks-cliservice.Lookupreads again for up to about 375 ms, in case another process is writing or deleting them, and then returns the token without an access token, whichPersistentAuth.Token()refreshes.Delete, and soauth logout, removes every part, the last one first, so that an interrupted logout leaves parts the next one finds.auth loginrejects profile names that contain#access-token-in any letter case (Windows Credential Manager ignores case).security -ibefore its size check and leaves the process behind.Why
Windows Credential Manager caps a credential at 2560 bytes, and go-keyring's macOS backend base64-encodes the entry into one
security -iline of at most 4096 bytes. One item therefore holds an access token of about 2.8 KB on macOS and 2.4 KB on Windows; the refresh token is only 36 bytes. The tokens in #7707 are about 3,250 bytes.Decisions to review
tokenfrom a split entry: not nil, because releases before v1.24 dereference it, and without the refresh token, because they would rotate it and then fail to store the result. They fail withtoken refresh: cached token has no refresh token, which asks for a new login.Deletemakes one extra call. Parts stay behind when a token shrinks or an older version logs out, until the nextDelete. A profile that an older version saved with#access-token-in its name can collide with another profile's parts.Tests
Delete, size changes on one key, and part errors and timeouts. Also a refresh without an access token and after a failed part write, the reserved name in any case at--profile(acceptance) and at the prompt, andTestDarwinCommandTooBig.Deletekeeping parts or starting from the first, a nil or refresh-carrying top-leveltoken, 4096-byte parts, and more) fails a named test.CIis set): round trips, a token that fits staying one item, size changes, the one-item boundary, a refresh throughPersistentAuth, andauth logout(TestKeyringStore_RealBackend_*,TestToken_RefreshesLargeTokenInOSKeyring,TestLogoutRemovesSplitTokenFromOSKeyring). On macOS,TestZalandoBackend_Set_RejectsLargeSecretWithoutSecurityProcesschecks that rejecting a large secret leaves nosecurityprocess behind../task testand lint for linux, darwin and windows pass.This pull request and its description were written by Isaac.