Skip to content

fix: show the actual error instead of a generic message when a request fails - #116

Merged
androemeda merged 1 commit into
mainfrom
fix/surface-real-api-errors
Sep 8, 2026
Merged

fix: show the actual error instead of a generic message when a request fails#116
androemeda merged 1 commit into
mainfrom
fix/surface-real-api-errors

Conversation

@androemeda

Copy link
Copy Markdown
Collaborator

Summary

Chat and biomodel analysis reported every failure with the same generic line, hiding the reason the backend actually gave. Both now show it.

The bugs

Chatuse-chat-history.tsx never checked res.ok. A rejected request still parses as JSON, so data.response came back undefined and fell through to "Sorry, I didn't get a response from the server." — while the real reason sat unread in data.detail. This affected every failure: rate limits, bad requests, and LiteLLM budget exhaustion, which is the one users are most likely to hit. It read like a server glitch, so the natural response was to retry, which failed the same way.

Analyzeanalyze/[id]/page.tsx threw away detail on a failed response, and its catch then overwrote the message with a hardcoded "Failed to analyze biomodel.", so both halves needed fixing.

Changes

  • New lib/api-error.ts — reads FastAPI's detail (string from HTTPException, or a list of objects from request validation), falling back when the body is missing or isn't JSON.
  • use-chat-history.tsx — check res.ok; show the reason, or The server returned an error (<status>). when there's no usable body. Network failures and cancellation keep their existing messages, which were already accurate.
  • analyze/[id]/page.tsx — throw the extracted message and preserve it through the catch.
  • profile/page.tsx — dropped a byte-identical local copy of the helper in favour of the shared one. No behaviour change.

VCMLSection and DiagramSection already handled this correctly and are untouched.

@androemeda
androemeda merged commit a69ea32 into main Sep 8, 2026
1 check passed
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.

1 participant