GPT-5 finding
createDirectConnectSession does not wrap JSON parsing in DirectConnectError, leaking raw exceptions
mediumbughigh
- src/server/createDirectConnectSession.ts:71
If the server returns invalid/non-JSON with HTTP 2xx, resp.json() throws and the function rejects with a raw error instead of the documented DirectConnectError, violating the API contract and complicating caller error handling.
Recommendation
Wrap resp.json() and schema validation in try/catch and rethrow a DirectConnectError with a clear message (e.g., "Invalid JSON in session response").