-
Notifications
You must be signed in to change notification settings - Fork 73
Closed
Description
Problem
The plugin's error handling doesn't follow the patterns used by OpenCode's official auth plugins (opencode-copilot-auth, opencode-anthropic-auth), causing errors to display incorrectly in the OpenCode UI.
Current behavior
-
Token refresh failures return a
Responseobject instead of throwing an error:return { success: false, response: new Response(JSON.stringify({ error: "Token refresh failed" }), { status: 401 }), };
-
API error responses are consumed, enriched with custom JSON, and returned as a new Response - this interferes with OpenCode's AI SDK error handling:
Impact
- Error messages persist incorrectly in the UI
- Rate limit errors may display as raw JSON instead of user-friendly messages
- Errors don't integrate with OpenCode's retry logic (
isRetryableflag)
Expected behavior
Based on opencode-copilot-auth (lines 88-89):
if (!response.ok) {
throw new Error(`Token refresh failed: ${response.status}`);
}- Token refresh failures should throw errors (OpenCode catches these and displays them properly)
- API error responses should be returned as-is (OpenCode's AI SDK converts HTTP errors to
APICallError→MessageV2.APIError)
References
- OpenCode error handling:
packages/opencode/src/session/message-v2.ts:fromError() - Official plugin pattern:
opencode-copilot-auth/index.mjs:88-89
Metadata
Metadata
Assignees
Labels
No labels