Skip to content

desktop: log and recover empty or failed token fetches - #3890

Merged
trungutt merged 3 commits into
docker:mainfrom
trungutt:log-empty-desktop-token
Aug 3, 2026
Merged

desktop: log and recover empty or failed token fetches#3890
trungutt merged 3 commits into
docker:mainfrom
trungutt:log-empty-desktop-token

Conversation

@trungutt

@trungutt trungutt commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Requests through the Docker AI Gateway fail with failed to get Docker Desktop token for Gateway. Is Docker Desktop running and are you signed in? whenever the token fetched from Docker Desktop comes back empty — yet this case leaves no trace anywhere: the fetch error was discarded, and unlike the expired-token case there was no log line and no recovery attempt.

GetToken()
  ├─ token EXPIRED → logged + forced refresh   (already handled)
  └─ token EMPTY / fetch error → silence       (this PR)

An empty result typically means Desktop's session exists but its read-time token refresh just failed (network blip, revoked refresh token) — the user is signed in, so the error message is misleading and there is nothing in the logs to attribute it to.

This PR makes the empty/failed fetch path behave like the expired path:

  • log why the token is unusable (fetch error, empty, or expired — with a safe fingerprint)
  • run the same forced refresh, but only when Desktop reports the user as signed in, so signed-out users don't pay the refresh polling budget on every request
  • surface HTTP error statuses from the backend client instead of masking them as JSON decode errors

@aheritier aheritier added the area/core Core agent runtime, session management label Aug 3, 2026
@trungutt
trungutt requested a review from docker-agent August 3, 2026 08:38
@trungutt
trungutt marked this pull request as ready for review August 3, 2026 08:43
@trungutt
trungutt requested a review from a team as a code owner August 3, 2026 08:43
@trungutt
trungutt merged commit fc2cbcb into docker:main Aug 3, 2026
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/core Core agent runtime, session management

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants