Skip to content

fix(auth): ignore stale unauthorized results after credential replacement#4565

Open
yinkev wants to merge 1 commit into
router-for-me:devfrom
yinkev:fix/auth-stale-failure-after-relogin
Open

fix(auth): ignore stale unauthorized results after credential replacement#4565
yinkev wants to merge 1 commit into
router-for-me:devfrom
yinkev:fix/auth-stale-failure-after-relogin

Conversation

@yinkev

@yinkev yinkev commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Summary

  • bind internally recorded execution results to the credential revision that actually ran
  • ignore only stale unauthorized failures after same-ID credential replacement
  • guard in-flight credential refreshes against replacement races
  • merge successful refresh credential changes onto the latest unrelated auth fields
  • preserve concurrent quota, cooldown, and operator state while a refresh is in flight
  • fingerprint API keys and metadata- or storage-backed OAuth credentials
  • suppress stale unauthorized Redis error events
  • persist cooldown cleanup when replacement credentials clear stale model state

Root cause

A same-filename re-login preserves the auth ID. An older request or refresh can finish after the replacement and previously mutate whichever credential currently occupied that ID.

Execution results now carry a one-way credential revision fingerprint. Refresh application uses credential-aware, generation-checked three-way merging:

  • credential revision changed: discard the old refresh result
  • credential unchanged, unrelated fields changed: apply only the refresh credential delta
  • concurrent availability state changed: preserve the newer quota/cooldown/operator state

Only stale unauthorized failures are credential-specific. Success, quota, and transient results from ordinary token rotation still apply to shared account/model state.

Credential coverage

  • API keys in auth attributes or metadata
  • OAuth fields in runtime metadata
  • Claude and Codex OAuth tokens retained only in token storage

Storage and metadata representations produce the same fingerprint material without logging or exposing tokens.

Validation

  • go test ./sdk/cliproxy/auth ./internal/api/handlers/management ./internal/auth/claude ./internal/auth/codex -count=1
  • focused race tests for execution-result replacement, refresh replacement, unrelated update merge, and concurrent availability state
  • go vet ./sdk/cliproxy/auth ./internal/api/handlers/management ./internal/auth/claude ./internal/auth/codex
  • go build -o /tmp/pr4565-server ./cmd/server
  • git diff --check upstream/dev...HEAD

Fixes #4123

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 151d457dba

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread sdk/cliproxy/auth/conductor.go
Comment thread sdk/cliproxy/auth/conductor.go Outdated
@yinkev
yinkev force-pushed the fix/auth-stale-failure-after-relogin branch from 151d457 to 3eb4995 Compare July 25, 2026 17:59

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3eb499525e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread sdk/cliproxy/auth/conductor.go
@yinkev
yinkev force-pushed the fix/auth-stale-failure-after-relogin branch from 3eb4995 to 7aa4541 Compare July 25, 2026 18:30
@yinkev

yinkev commented Jul 25, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7aa454122b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread sdk/cliproxy/auth/conductor.go
@yinkev
yinkev force-pushed the fix/auth-stale-failure-after-relogin branch from 7aa4541 to e0783de Compare July 25, 2026 20:13
@yinkev

yinkev commented Jul 25, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e0783de18e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread sdk/cliproxy/auth/conductor.go
@yinkev
yinkev force-pushed the fix/auth-stale-failure-after-relogin branch from e0783de to 959ab94 Compare July 25, 2026 20:34
@yinkev

yinkev commented Jul 25, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: 959ab94e6c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

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