Skip to content

Fall back to the public URL when a Google login fails to refresh (0.10.1) - #17

Merged
davidackerman merged 3 commits into
mainfrom
gcs-stale-login
Nov 13, 2026
Merged

davidackerman merged 3 commits into
mainfrom
gcs-stale-login

Conversation

@davidackerman

Copy link
Copy Markdown
Member

A gs:// open with a stale Google login now falls back to the bucket's public https URL, as kvstore_specs intends for credentials that exist but don't work.

cellmap-flow found this on David's Mac. cellmap_flow view -d precomputed://gs://neuroglancer-janelia-flyem-hemibrain/emdata/clahe_yz/jpeg raised, although the public https form of that volume opens fine. His application_default_credentials.json had expired under the Workspace reauth policy, and Google refuses such a refresh with HTTP 400 invalid_grant. tensorstore reports that as Unknown [HTTP code 400] ... (0.1.78: Bad Request [http_response_code='400'] ...). is_refused only matched PERMISSION_DENIED and UNAUTHENTICATED, so with_access raised instead of trying the next way. A 401 from the token endpoint (a bad client secret) already fell back, because tensorstore reports it as PERMISSION_DENIED.

Changes, in store.py:

  • login_failed(error) is true when tensorstore names its internal/oauth2/ code among the error's source locations, which is to say the error came from getting the access token. It covers a stale login, a rejected client, and a token endpoint out of reach. is_refused now counts these. The message shapes on tensorstore 0.1.68, 0.1.78 and David's Mac build all carry that source location.
  • Probe reads (_read_keys and read_many) treat a failed login as an answer to no key. The other keys' reads are cancelled and the next way is tried at once. A failed login is never read as "missing", which the listing-off-bucket rule allows for a plain 403.
  • with_access: when the last way fails too, after a refusal, its error carries the first refusal as __cause__. For a private bucket with a stale login, the raised error is the public URL's 403, and the traceback still shows the invalid_grant above it.

Not changed: retries. A token endpoint out of reach (UNAVAILABLE) is still retried under Retry before the fallback, as any transient error is. A 400 is not transient and moves on at once.

Tests (tests/test_access.py):

  • A unit test covers is_refused on the 400 and on an unreachable token endpoint, and not on a plain 400. It also checks the fallback and the chained cause with a fake attempt.
  • An end-to-end test reproduces the failure offline. An https proxy plays www.googleapis.com under a test CA made with openssl (tensorstore trusts it through TENSORSTORE_CA_BUNDLE) and answers every token refresh 400 invalid_grant. A local http server is the public URL (TENSORSTORE_GCS_HTTP_URL), and a subprocess with an authorized_user login opens gs://bucket/vol.zarr/s0 and reads it. The test is skipped where openssl is missing.
  • Both fail on main and pass here. The full suite passes: 206 passed, 1 skipped, on tensorstore 0.1.78 and 0.1.68. The strict mkdocs build passes.

This is a patch release (0.10.1) under the spec's §8 rule, since it reads where 0.10.0 raised. There's no placement change, no unit table change, and no default change. The spec (Conventions 5 and its test line) and the CHANGELOG are updated. The changelog entry is marked unreleased until it's dated at release.

https://claude.ai/code/session_0141wgF8mkGbjGfBFKfKhp64

…0.1)

An expired gcloud login is refused at the token endpoint with HTTP 400
invalid_grant, which tensorstore reports as neither PERMISSION_DENIED nor
UNAUTHENTICATED, so a gs:// open raised instead of reading a public bucket
through its https URL. An error from getting the access token (tensorstore's
internal/oauth2/ code among its source locations) now counts as a refusal and
ends the probe reads at once; when every way in fails after a refusal, the
error raised carries the first refusal as its cause. Found by cellmap-flow on
David's Mac.

Claude-Session: https://claude.ai/code/session_0141wgF8mkGbjGfBFKfKhp64
@davidackerman
davidackerman merged commit ec13627 into main Nov 13, 2026
4 checks passed
@davidackerman
davidackerman deleted the gcs-stale-login branch November 13, 2026 17:05
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.

1 participant