Skip to content

Missing HTTP Status Checks in AuthModal #2600

@subhamkumarr

Description

@subhamkumarr

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions