Phase 3: contract integrity and observability (frontend) - #4
Merged
Conversation
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0114vatC9EkHGSUN9zGfAT3G
resp.json() threw a raw SyntaxError on anything that wasn't the JSON this API always sends -- a gateway timeout, a proxy's HTML error page, a truncated connection. It propagated past every caller that catches ApiError specifically, as "Unexpected token < in JSON at position 0" rather than anything a user could read. Wrapped in try/catch, now a typed ApiError instead. 204 handled before the parse is ever attempted -- calling .json() on a body-less response throws too, and while nothing in this contract sends one today, a proxy in front of the API could produce one regardless of what the handler wrote. No unit test: the frontend has no unit-test runner yet (BV-057 is the tracked first target for one), and this path isn't practically reachable through the e2e suite without mocking network failures Playwright would need route interception to fake convincingly. Verified with tsc, lint and build; the change is defensive and does not alter any success-path behaviour those already cover. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0114vatC9EkHGSUN9zGfAT3G
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
🟢 Approval recommended
The changes are small, localized, align with the PR goals, and don’t introduce contract or behavior mismatches with the currently documented endpoint response types.
Pull request overview
This PR updates the frontend API client to surface more user-readable failures when the backend (or an intermediary) returns a non-JSON response, and refreshes generated OpenAPI types to match the latest Health contract.
Changes:
- Handle HTTP 204 responses in the API request wrapper by treating them as a successful empty response (avoids
.json()parse failures on no-content responses). - Wrap
resp.json()intry/catchand convert JSON parse failures into anApiErrorwith a readable message. - Regenerate
openapi.d.tsto include the newHealth.contractViolationsfield.
File summaries
| File | Description |
|---|---|
| src/services/api.ts | Improves resilience and user-facing error messaging when responses are empty (204) or non-JSON. |
| src/types/openapi.d.ts | Updates generated Health type to include contractViolations. |
Review details
- Files reviewed: 1/2 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
subhanlone
changed the base branch from
fix/phase-2-abuse-resistance
to
master
August 30, 2026 22:04
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
Stacked on Phase 2 (not yet merged). Frontend companion to bidvault-backend's Phase 3 PR.
Test plan
Generated with Claude Code
https://claude.ai/code/session_0151oceeiAyJdi6T273spk4P