fix: show the actual error instead of a generic message when a request fails - #116
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
Chat —
use-chat-history.tsxnever checkedres.ok. A rejected request still parses as JSON, sodata.responsecame backundefinedand fell through to "Sorry, I didn't get a response from the server." — while the real reason sat unread indata.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.Analyze —
analyze/[id]/page.tsxthrew awaydetailon a failed response, and itscatchthen overwrote the message with a hardcoded "Failed to analyze biomodel.", so both halves needed fixing.Changes
lib/api-error.ts— reads FastAPI'sdetail(string fromHTTPException, or a list of objects from request validation), falling back when the body is missing or isn't JSON.use-chat-history.tsx— checkres.ok; show the reason, orThe 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 thecatch.profile/page.tsx— dropped a byte-identical local copy of the helper in favour of the shared one. No behaviour change.VCMLSectionandDiagramSectionalready handled this correctly and are untouched.