Skip to content

Block OpenCode Go cookie leakage on redirects#969

Closed
pavbar wants to merge 2 commits into
steipete:mainfrom
tsh-third-party:opencode-go-cookie-redirect-fix
Closed

Block OpenCode Go cookie leakage on redirects#969
pavbar wants to merge 2 commits into
steipete:mainfrom
tsh-third-party:opencode-go-cookie-redirect-fix

Conversation

@pavbar

@pavbar pavbar commented May 16, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add a guarded URLSession for OpenCode Go usage requests
  • block cross-host and non-HTTPS redirects so cookies are not forwarded away from opencode.ai
  • keep same-host HTTPS redirects working and preserve injected test sessions

Verification

  • swift test --filter OpenCodeGoUsageFetcherErrorTests
  • fresh review passes against the PR diff found no remaining OpenCode Go issues

Note: branch name intentionally avoids slashes so the fork's current push CI branch pattern can match it.

@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: a79b06c489

ℹ️ 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 on lines +48 to +50
else {
completionHandler(nil)
return

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Treat blocked auth redirects as invalid credentials

When this delegate cancels a cross-host redirect with completionHandler(nil), URLSession returns the original 3xx response to fetchServerText/fetchPageText, which currently maps most non-200 responses to .apiError unless the body contains login text. If OpenCode expires a session by redirecting to a login/auth host (a common pattern), this change turns an auth-expiry case into a generic API error, so the retry path in OpenCodeGoUsageFetchStrategy (which only catches .invalidCredentials) no longer runs and users can get stuck with stale cookies.

Useful? React with 👍 / 👎.

@steipete

Copy link
Copy Markdown
Owner

Thanks @pavbar. I landed this via #979 because this token could not push the small regression-test/changelog fixups back to the contributor fork.

The landed version keeps the PR behavior, adds a direct regression test for same-host HTTPS redirect gating, and credits you in the changelog.

Landed: #979 / 53d675f.

@steipete steipete closed this May 16, 2026
@pavbar
pavbar deleted the opencode-go-cookie-redirect-fix branch May 16, 2026 17:21
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.

2 participants