Skip to content

ChatGPT login: read the device code's interval as a number or a numeric string - #302

Merged
fylorn merged 1 commit into
mainfrom
fix/device-code-interval-string
Oct 9, 2026
Merged

fylorn merged 1 commit into
mainfrom
fix/device-code-interval-string

Conversation

@fylorn

@fylorn fylorn commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

OpenAI's device code endpoint now answers "interval": "5" instead of 5. Reading it as u64 failed, so Sign in on another device for a ChatGPT account stopped at The answer to the device code request could not be read: invalid type: string "5", expected u64 at line 4 column 17.

  • New tw_gateway::lenient::seconds: a non-negative integer or a string of digits (surrounding whitespace allowed); anything else is treated as not given. seconds_or_zero is the serde adapter.
  • Used for the device code's interval (unknown → 0, so polling falls back to its lower bound), expires_in in the ChatGPT token answer and the generic OAuth refresh answer, and Z.ai's poll_interval_sec / expires_at — the same kind of field, so the same change in format doesn't break those logins either.
  • Tests: the helper's accepted/refused forms, and the device code read with "5", 5, missing and garbage.

Checks: cargo fmt --check, cargo clippy --workspace --all-targets -D warnings, cargo test --workspace (3081 passed).

🤖 Generated with Claude Code

…ic string

OpenAI's device code endpoint now answers `"interval": "5"` instead of `5`, so
reading it as u64 failed and "Sign in on another device" stopped at "The answer
to the device code request could not be read: invalid type: string \"5\",
expected u64".

A new `tw_gateway::lenient::seconds` reads a non-negative integer or a string
of digits; anything else counts as not given. It reads the device code's
interval (unknown → 0, so polling uses its lower bound), `expires_in` in the
ChatGPT and generic OAuth token answers, and Z.ai's `poll_interval_sec` and
`expires_at`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@fylorn
fylorn merged commit 66eeefb into main Oct 9, 2026
5 checks passed
@fylorn
fylorn deleted the fix/device-code-interval-string branch October 9, 2026 06:37
@fylorn fylorn mentioned this pull request Oct 9, 2026
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