You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Unprotected JSON.parse in provider fetch wrapper can crash requests #11698
The provider fetch wrapper contains an unprotected JSON.parse call that can crash API requests if the body is malformed.
Location
packages/opencode/src/provider/provider.ts:1010
Issue
if(model.api.npm==="@ai-sdk/openai"&&opts.body&&opts.method==="POST"){constbody=JSON.parse(opts.bodyasstring)// NO TRY-CATCHconstisAzure=model.providerID.includes("azure")// ...}
If opts.body is not valid JSON (which shouldn't happen normally, but could due to a bug elsewhere), this will throw an unhandled error and crash the entire request.
Impact
Severity: Medium
Type: Error Handling
Effect: Malformed request bodies cause unhandled exceptions
Suggested Fix
Wrap in try-catch:
if(model.api.npm==="@ai-sdk/openai"&&opts.body&&opts.method==="POST"){try{constbody=JSON.parse(opts.bodyasstring)constisAzure=model.providerID.includes("azure")// ... rest of logic}catch(e){// Log warning and continue with original bodylog.warn("failed to parse request body for ID stripping",{error: e})}}
Activity
github-actions commentedon Feb 2, 2026
This issue might be a duplicate of or closely related to existing error handling issues. Please check:
These are part of a broader pattern of insufficient error handling in critical code paths that deserves systematic review and fixes.
Feel free to ignore if this specific case addresses your particular scenario.
github-actions commentedon Apr 3, 2026
To stay organized issues are automatically closed after 90 days of no activity. If the issue is still relevant please open a new one.