harden API response handling#564
Merged
Merged
Conversation
Workflow detail crashes on missing workflow IDs because the shared 404 parser still expects the older `error.msg` response shape. When the backend returns the current top-level `message` field, the page throws before the route can render the not-found state. Teach the API client to read the current `message` field, fall back to the legacy nested field, and use a generic message if neither is present. Add a regression test that exercises `getWorkflow` against the current 404 envelope so the route keeps surfacing the backend error.
API routes can fall back to the app shell when a route is missing or misconfigured, producing a successful HTML response where callers expect JSON. The previous client attempted to parse every successful response as JSON, which hid the real routing problem behind a low-level parse error. Send an explicit JSON `Accept` header, validate successful response content types before parsing, and surface structured response errors for unexpected or failed responses. Add coverage for the app-shell fallback case so future route regressions fail with a useful API error.
brandur
approved these changes
May 8, 2026
a19e303 to
e6a0f7b
Compare
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.
API callers could crash or surface low-level parse errors when the backend returned the current top-level
messageerror envelope or when a missing API route fell through to the HTML app shell.This updates the shared API client to read both current and legacy 404 envelopes, request JSON explicitly, validate successful response content types before parsing, and raise structured response errors for unexpected responses.
The branch includes focused API client coverage for workflow not-found responses and app-shell fallback responses.