Skip to content

fix(auth): recover from corrupt stored OAuth token#874

Merged
steipete merged 1 commit into
mainfrom
clawsweeper/issue-openclaw-gogcli-872
Jun 23, 2026
Merged

fix(auth): recover from corrupt stored OAuth token#874
steipete merged 1 commit into
mainfrom
clawsweeper/issue-openclaw-gogcli-872

Conversation

@clawsweeper

@clawsweeper clawsweeper Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Closes #872

Summary

  • Add a secrets-level classifier/sentinel for stored OAuth token JSON decode corruption.
  • Treat only missing tokens and classified corrupt stored tokens as re-auth-required in the Google API auth path.
  • Preserve fatal handling for operational token-store errors such as locked keychains, permission failures, wrong file-backend passwords, migration/read-back failures, and arbitrary store errors.

Release note

Corrupt stored OAuth token JSON now surfaces the normal re-auth guidance instead of making every command fail with a fatal decode error.

Validation

  • go test ./internal/secrets ./internal/googleapi
  • make ci

@clawsweeper clawsweeper Bot added clawsweeper Tracked by ClawSweeper automation clawsweeper:autogenerated PR created automatically by ClawSweeper clawsweeper:autofix Bounded ClawSweeper-reviewed autofix without merge labels Jun 23, 2026
@clawsweeper

clawsweeper Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor Author

Codex review: passed. Reviewed June 23, 2026, 3:44 AM ET / 07:44 UTC.

Summary
The branch adds secrets.ErrCorruptStoredToken, wraps stored OAuth token JSON decode failures with it, maps that sentinel to AuthRequiredError, and adds focused auth/secrets regression tests.

Reproducibility: yes. Current main is source-reproducible: corrupt stored token JSON returns a generic decode error and the caller only maps missing keyring entries to re-auth; I did not execute tests because this review is read-only.

Review metrics: 2 noteworthy metrics.

  • Patch scope: 4 files changed, 80 added, 3 removed. The diff is localized to token classification, auth routing, and focused regression tests.
  • Regression coverage: 4 tests added. The added tests cover the corrupt-token sentinel, missing-token separation, subject-token corruption, and caller-level auth-required mapping.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #872
Summary: The linked issue is the canonical corrupt-token auth recovery bug, and this PR is its active candidate fix.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🌊 off-meta tidepool
Patch quality: 🐚 platinum hermit
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P2] Wait for the in-progress CI jobs to finish before merge.

Risk before merge

  • [P1] The latest GitHub status check rollup still had test and Windows jobs in progress, so merge should wait for the required CI result.

Maintainer options:

  1. Decide the mitigation before merge
    Land this narrow sentinel-based fix after required CI is green, keeping operational keyring/backend errors fatal while routing corrupt stored credentials to re-auth.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • No automated repair lane is needed because the PR has no concrete code blocker; maintainers can review and merge after CI passes.

Security
Cleared: The diff only changes internal auth error classification and tests; it adds no dependency, workflow, permission, secret-storage, or supply-chain surface.

Review details

Best possible solution:

Land this narrow sentinel-based fix after required CI is green, keeping operational keyring/backend errors fatal while routing corrupt stored credentials to re-auth.

Do we have a high-confidence way to reproduce the issue?

Yes. Current main is source-reproducible: corrupt stored token JSON returns a generic decode error and the caller only maps missing keyring entries to re-auth; I did not execute tests because this review is read-only.

Is this the best way to solve the issue?

Yes. The PR uses the narrow sentinel/classifier approach requested by the linked report, so corrupt present tokens can re-auth without masking operational keyring errors.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against fc13b4147e20.

Label changes

Label changes:

  • add P2: A corrupt stored OAuth token can block commands for the affected account, but the fix is localized and the blast radius is limited.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This is a bot-generated ClawSweeper autofix PR, so the external-contributor real behavior proof gate does not apply.

Label justifications:

  • P2: A corrupt stored OAuth token can block commands for the affected account, but the fix is localized and the blast radius is limited.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This is a bot-generated ClawSweeper autofix PR, so the external-contributor real behavior proof gate does not apply.
Evidence reviewed

What I checked:

Likely related people:

  • Peter Steinberger: History shows Peter split internal/secrets/token.go, refactored injected Google API auth dependencies, and authored much of the current token-source and keyring code around this path. (role: recent auth/keyring area contributor; confidence: high; commits: 978dd0d14988, 05b75b44cd41, 1531013e50b6; files: internal/secrets/token.go, internal/secrets/store.go, internal/googleapi/client_auth.go)
  • Lachlan Donald: Recent history shows Lachlan worked on keyring prompt-storm and token-read behavior adjacent to corrupt or unavailable token storage handling. (role: adjacent auth/keyring contributor; confidence: medium; commits: c58b381c97ad; files: internal/secrets/token.go, internal/secrets/store_more_test.go, internal/cmd/auth_list_helpers.go)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P2 Normal priority bug or improvement with limited blast radius. labels Jun 23, 2026
@steipete
steipete merged commit 7795543 into main Jun 23, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clawsweeper:autofix Bounded ClawSweeper-reviewed autofix without merge clawsweeper:autogenerated PR created automatically by ClawSweeper clawsweeper Tracked by ClawSweeper automation P2 Normal priority bug or improvement with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: corrupt stored token fails fatally on every command instead of prompting re-auth

1 participant