Repository navigation
fix(core): add vpn hint to free tier and rate limit errors - #56475
JayadityaGit wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
The free-tier error now gets the hint as described, but the rate-limit match is too broad to merge as is.
I checked it by calling toSessionError on the base and on this PR with a free-tier AuthenticationError and with a non-OpenCode RateLimitError. I also ran bun test test/session-error.test.ts (passes) and bun run typecheck in packages/core (clean).
Public API: unchanged. Only the text of SessionError messages changes; no types, events or config keys change.
Concerns:
- Applies to every provider.
message.includes("Rate limit exceeded")runs on every provider's errors. A plain Anthropic/OpenRouter/OpenAI 429 such asRate limit exceeded: … per-minute quotanow ends with "If you are using a VPN or proxy, try disconnecting it.", which is misleading there. Please limit the hint to errors from the OpenCode gateway, matching on something structured such as a gateway error code inreason.body, the waytokenSharingMessagesdoes, rather than on English message text. The gateway may also be a better place for this hint, since it owns both messages. - Model-visible text. The changed message is also what the model sees as the error, so any hint added here reaches the model too. Keep it tightly scoped.
Related: #56334, #56398, #56373, #56397, #56425, #56338, #56111, #56431
| } | ||
|
|
||
| function vpnHint(message: string) { | ||
| if (message.includes("can only be used from within OpenCode") || message.includes("Rate limit exceeded")) { |
There was a problem hiding this comment.
providerError runs for every provider, so "Rate limit exceeded" also matches ordinary 429s from Anthropic, OpenRouter, OpenAI and others. I checked: Rate limit exceeded: anthropic/claude per-minute quota becomes … per-minute quota. If you are using a VPN or proxy, try disconnecting it. Could this be limited to the OpenCode gateway's errors, e.g. by matching a gateway error code in reason.body like tokenSharingMessages does, instead of English message substrings?
There was a problem hiding this comment.
thanks for pointing it out


Issue for this PR
Closes #56474
Type of change
What does this PR do?
When requests fail due to VPN or proxy IP filtering (\can only be used from within OpenCode) or shared IP rate limiting (\Rate limit exceeded), this PR appends \If you are using a VPN or proxy, try disconnecting it.\ to the error message in \ oSessionError. This prevents users from assuming their local client or auth is corrupted.
How did you verify your code works?
Added unit tests in \packages/core/test/session-error.test.ts\ verifying both error messages are enriched correctly, and ran \�un test packages/core/test/session-error.test.ts\ (11/11 tests pass).
Screenshots / recordings
N/A (terminal error message enhancement)
Checklist
Added by the opencode bot (AI-generated).
Related: #56334, #56398, #56373, #56397, #56425, #56338, #56111, #56431