Skip to content

Conversation

@subhamkumarr
Copy link
Contributor

@subhamkumarr subhamkumarr commented Dec 26, 2025

Problem

Missing HTTP status checks in authentication flow cause crashes when APIs return error status codes (401, 403, 500).

Solution

Added response.ok checks before parsing JSON in both fetch calls:

  • Projects API call
  • User info API call

Changes

  • Added status checks before response.json() calls
  • Throws descriptive errors that are caught by existing error handling
  • Prevents crashes and incorrect data storage

Before:

const response = await fetch(...)
const data = await response.json()  // ❌ No check

After:

const response = await fetch(...)
if (!response.ok) throw new Error(`Failed: ${response.status}`)  // ✅
const data = await response.json()

Impact:

✅ Prevents authentication crashes
✅ Proper error handling
✅ Better user experience

Fixes #2600


Note

Strengthens error handling in auth and JSON-RPC data fetching paths.

  • Auth: In AuthModal.tsx, check projectsResponse.ok and uksUserRawResp.ok before response.json(); throw descriptive errors on non-OK to avoid crashes and bad session storage.
  • Plugin: In plugin-json-rpc.ts, update fetchData to validate response.ok and return { error: Error } on non-OK; catch now normalizes to an Error instance instead of a boolean flag.

Written by Cursor Bugbot for commit 473fd59. This will update automatically on new commits. Configure here.

@subhamkumarr subhamkumarr requested review from a team as code owners December 26, 2025 20:35
@vercel
Copy link

vercel bot commented Dec 26, 2025

@subhamkumarr is attempting to deploy a commit to the Consensys Team on Vercel.

A member of the Team first needs to authorize it.

@subhamkumarr
Copy link
Contributor Author

@AyushBherwani1998, could you please review this and merge it when you get a chance? Thanks!
Fixes #2600

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing HTTP Status Checks in AuthModal

1 participant