GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(core): ask to reconnect ChatGPT when its refresh token is rejected by hearnadam · Pull Request #65289 · anomalyco/opencode

Conversation

@hearnadam

@hearnadam hearnadam commented Nov 21, 2026 •
edited by opencodejr Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Issue for this PR

Closes #60133

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

When a ChatGPT sign-in's refresh token has been revoked or has expired, OpenAI's token endpoint answers 400 with {"error":"invalid_grant"}. request() dropped the body, so every prompt failed with "Request failed: 400" and nothing told the user to reconnect.

refresh() now turns that response into "This ChatGPT sign-in has expired or was revoked. Connect again." Only invalid_grant on the refresh grant is matched. Other failures, and the authorization-code exchange, keep their current errors.

This does not add a "needs sign in" status for the connection. The refresh runs in core rather than in the plugin, so where that status would be set needs a decision and is left out of this PR.

How did you verify your code works?

  • Added a test in provider-chatgpt.test.ts that runs refresh() against a local server. invalid_grant gives the new message; a 400 with a different error and a 500 still give "Request failed: ". The test fails without the fix.
  • bun run test test/plugin/provider-chatgpt.test.ts and bun typecheck in packages/core, and bun run check at the root.
  • Confirmed the response shape by posting an invalid refresh token to the real token endpoint, which returned 400 {"error":"invalid_grant"}. I have not tested against a real sign-in whose token was revoked.

Screenshots / recordings

Not a UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Added by the opencode bot (AI-generated).

Related: #55211

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@hearnadam
fix(core): ask to reconnect ChatGPT when its refresh token is rejected
c678f67
opencodejr[bot]
opencodejr Bot reviewed Nov 21, 2026
View reviewed changes

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

The change looks sound to me. When OpenAI rejects a refresh with invalid_grant, the new message replaces the bare 400. It reaches users unchanged through Integration.AuthorizationError. I couldn't run it end to end, because that needs a real ChatGPT sign-in whose token has been revoked. Instead I ran refresh() against a local server. Without the fix, the invalid_grant case fails with "Request failed: 400". With the fix, the new message appears, and other 400s and 500s keep their current error. The package's tests and tsc -b pass.

The export with a default URL follows the pattern revoke already uses. The invalid_grant check matches the existing handling in opencode.ts. The test is small and uses a local server, not the real network.

Public API: unchanged. refresh is a newly exported function inside core only.

No blocking concerns.

Related: #55211

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@hearnadam
hearnadam requested a balanced review from Copilot November 21, 2026 00:25
@hearnadam hearnadam assigned rekram1-node Nov 21, 2026
Copilot started reviewing on behalf of hearnadam November 21, 2026 00:25
View session
Copilot AI reviewed Nov 21, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

🟡 Changes recommended

The reconnect-message branch incorrectly handles non-400 responses containing invalid_grant, masking server errors as expired sign-ins instead of preserving the existing HTTP error.

1 open issue
  • Medium severity Limit invalid_grant reconnect messaging to HTTP 400 · New
What changed in this PR

Improves ChatGPT OAuth refresh errors in core so users are told to reconnect when their refresh token is rejected, addressing the unclear prompt failures reported in #60133. Authorization-code exchange behavior and connection status remain unchanged.

Changes:

  • Recognizes invalid_grant responses during refresh and supplies an actionable reconnect message.
  • Adds local-server tests for rejected refresh tokens and other HTTP failures.
File Description
packages/​core/​test/​plugin/​provider-chatgpt.test.ts Tests reconnect messaging and fallback HTTP errors.
packages/​core/​src/​plugin/​provider/​chatgpt.ts Decodes refresh rejection responses and provides the reconnect message.

Review effort: Balanced

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread packages/core/src/plugin/provider/chatgpt.ts
if (!response.ok) throw new Error(`Request failed: ${response.status}`)
return response.json() as Promise<A>
if (response.ok) return response.json() as Promise<A>
if (rejected && Option.isSome(decodeInvalidGrant(await response.text()))) throw new Error(rejected)
@github-actions github-actions Bot mentioned this pull request Nov 21, 2026
📊 AI CLI 工具社区动态日报 2026-11-21 litang9/big_model_radar#736
Open
@hearnadam
hearnadam merged commit 5310e42 into anomalyco:dev Nov 22, 2026
13 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@kelos-bot kelos-bot Bot mentioned this pull request Nov 22, 2026
[kanon-fake-strategist] Render hooks per agent capability and add OpenCode hook support kelos-dev/kanon#100
Open
@BrewTestBot BrewTestBot mentioned this pull request Nov 23, 2026
opencode 2.4.0 Homebrew/homebrew-core#327368
Merged
@amrkmn amrkmn mentioned this pull request Nov 23, 2026
opencode 2.4.0 amrkmn/homebrew-tap#1251
Closed
1 task
@github-actions github-actions Bot mentioned this pull request Nov 23, 2026
feat: opencode release v2.4.0 sprisa/opencode-server#95
Merged
@kobzevvv kobzevvv mentioned this pull request Nov 24, 2026
chore(upstream): порт v2.4.1 — 67 в порт, 38 на решение gpt-mem/opencode-mem#223
Open
4 tasks
@hearnadam
hearnadam deleted the chatgpt-reconnect-error branch November 24, 2026 21:02
@devin-ai-integration devin-ai-integration Bot mentioned this pull request Nov 25, 2026
upstream: provider/security fixes not yet ported AltimateAI/altimate-code#1478
Open
29 of 90 tasks
@scottames-github-bot scottames-github-bot Bot mentioned this pull request Nov 27, 2026
chore(deps): update ⬆️ mise-packages scottames/dots#1181
Merged
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

Copilot code review Copilot
Copilot review effort
Applies to this pull request for everyone.Learn more about Copilot code review.
Copilot left review comments
@opencodejr opencodejr[bot] opencodejr[bot] left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@rekram1-node rekram1-node

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

ChatGPT OAuth connection fails with Request failed: 400 until reconnected

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@hearnadam @rekram1-node
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.