-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Open
Description
Problem
The AuthModal component doesn't check the HTTP response status before parsing JSON. When APIs return error codes (401, 403, 500), the code attempts to parse error responses as JSON, causing application crashes.
Location: src/components/AuthLogin/AuthModal.tsx (lines 250, 259)
Current code:
const response = await fetch(...)
const { result: { projects } } = await response.json() // ❌ No status check- Authentication crashes when APIs return errors
- "Cannot read property of undefined" errors
- Incorrect data stored in sessionStorage
Solution
Add if (!response.ok) checks before parsing JSON, similar to the fix in plugin-json-rpc.ts.
Example Fixipt
if (!response.ok) {
throw new Error(`Failed: ${response.status}`)
}
const data = await response.json()
Metadata
Metadata
Assignees
Labels
No labels