Skip to content

Phase 3: contract integrity and observability (frontend) - #4

Merged
subhanlone merged 2 commits into
masterfrom
fix/phase-3-contract-observability
Aug 30, 2026
Merged

Phase 3: contract integrity and observability (frontend)#4
subhanlone merged 2 commits into
masterfrom
fix/phase-3-contract-observability

Conversation

@subhanlone

Copy link
Copy Markdown
Owner

Summary

Stacked on Phase 2 (not yet merged). Frontend companion to bidvault-backend's Phase 3 PR.

  • BV-023: api.ts wraps resp.json() in try/catch and handles 204, so a non-JSON response (a gateway timeout, a proxy error page) surfaces a readable message instead of a raw SyntaxError.
  • Regenerated openapi.d.ts for the Health schema's new contractViolations field.

Test plan

  • npm run build
  • npm run lint
  • CI green on this PR

Generated with Claude Code

https://claude.ai/code/session_0151oceeiAyJdi6T273spk4P

subhanlone and others added 2 commits August 30, 2026 16:39
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
Copilot AI lite review requested due to automatic review settings August 30, 2026 21:54
@vercel

vercel Bot commented Aug 30, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
bidvault Ready Ready Preview Aug 30, 2026 9:54pm

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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() in try/catch and convert JSON parse failures into an ApiError with a readable message.
  • Regenerate openapi.d.ts to include the new Health.contractViolations field.
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
subhanlone changed the base branch from fix/phase-2-abuse-resistance to master August 30, 2026 22:04
@subhanlone
subhanlone merged commit ef595ed into master Aug 30, 2026
4 of 5 checks 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.

2 participants