Skip to content

fix(openai-codex-auth): clear stale error fields on successful auth - #404

Draft
rita-aga wants to merge 1 commit into
mainfrom
claude/codex-auth-clear-error-on-success
Draft

fix(openai-codex-auth): clear stale error fields on successful auth#404
rita-aga wants to merge 1 commit into
mainfrom
claude/codex-auth-clear-error-on-success

Conversation

@rita-aga

Copy link
Copy Markdown
Collaborator

What

Clears the stale error / error_message fields on the OpenAICodexAuth entity when auth succeeds (device login, token refresh, or already-fresh check).

Why

set_success_result writes status + success fields and merges into existing entity state, so a prior failure's error text persisted after a successful login. provider_auth_gate decides off status (blocking set: starting/devicecodeready/polling/refreshing/disconnected/idle), so this never blocked sessions — but the lingering error misled diagnosis.

Observed 2026-06-16: after a clean Codex re-login (status Ready, fresh token, sessions calling gpt-5.5 successfully), the entity still showed HTTP 401 ... "code":"refresh_token_reused", which sent an operator down the wrong path.

Change

  • Add with_cleared_error(fields) — blanks error + error_message.
  • Apply it to the three success / in-progress set_success_result sites: start_device_login, the already-fresh branch of ensure_tokens_fresh, and store_tokens_and_complete.
  • Unit test with_cleared_error_blanks_error_fields_and_preserves_rest.

Verification

  • cargo test (openai-codex-auth) — 4 passed, incl. the new test.

Deploy note

Cosmetic/diagnostic only; the auth gate is unaffected. Recommend shipping with the next paw-agent release rather than a standalone Genesis republish, to avoid clobbering in-flight paw-agent work.

🤖 Generated with Claude Code

A successful device login / token refresh / already-fresh check left the
prior failure's `error` and `error_message` on the OpenAICodexAuth entity,
because set_success_result writes status + success fields and merges into
existing state. provider_auth_gate keys off `status` (so this never blocked
sessions), but the stale text misled operators diagnosing Codex auth — a
clean re-login still surfaced the old `refresh_token_reused` message.

Add `with_cleared_error` to blank both fields on every success/in-progress
result: start_device_login, the already-fresh path, and
store_tokens_and_complete. Unit test covers the helper.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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