Skip to content

fix(frontend): gql() crashes with SyntaxError on non-JSON error responses #596

@Riviya

Description

@Riviya

Description

gql() in frontend/src/api/graphql.ts calls await res.json() without
checking res.ok first. If the server returns a 401/500 with an HTML error
page, res.json() throws an opaque SyntaxError instead of a useful API error.

Fix

  • Read response as text first, then attempt JSON.parse in a try/catch
  • Check res.ok before accessing response data
  • Surface HTTP status and body preview in thrown errors

Frontend-only change. File affected: frontend/src/api/graphql.ts

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions