Skip to content

fix: normalize non-OK API responses#2

Closed
YfengJ wants to merge 2 commits into
2lll5:mainfrom
YfengJ:codex/api-error-normalization
Closed

fix: normalize non-OK API responses#2
YfengJ wants to merge 2 commits into
2lll5:mainfrom
YfengJ:codex/api-error-normalization

Conversation

@YfengJ

@YfengJ YfengJ commented Jun 20, 2026

Copy link
Copy Markdown

Summary

Fixes #1.

Normalizes non-2xx HTTP responses in the shared frontend API client into ApiError objects so callers no longer receive 4xx/5xx responses as successful ApiResponse<T> values.

Changes

  • Convert non-OK fetch responses into ApiError before the success response-interceptor path.
  • Preserve HTTP status, request ID, path, response body details, and actionable suggestions for JSON and text error bodies.
  • Keep timeout and network failures on the existing normalizeError path.
  • Avoid retrying ordinary 4xx GET responses while keeping retry behavior for transient failures such as timeout, 429, and 5xx.
  • Add documented validation notes for 2xx success, 401 JSON, 429, 500 text, aborted request, and network failure cases.
  • Include diagnostic/build-b172b833.json from the required python3 build.py run. The encrypted .logd could not be created because the local encryptly preflight fails before module builds.

Testing

  • cd frontend && npm ci --ignore-scripts --no-audit --no-fund
  • cd frontend && npm run build passes.
  • git diff --check passes.
  • python3 build.py was run and failed in the required diagnostic preflight because encryptly cannot run in this environment. It generated and committed diagnostic/build-b172b833.json; no .logd was produced.

Checklist

  • Relevant modules affected by these changes build locally
  • Tests pass locally
  • Diagnostic build log is committed in this PR
  • Documentation has been updated, if applicable
  • Configuration or schema changes are documented, if applicable
  • No generated build artifacts are committed, except the required diagnostic build log
  • Changes are scoped to the PR purpose and avoid unrelated cleanup
  • Security, privacy, and error-handling implications have been considered

  • I would like to request that my diagnostic build log is removed before merging

@YfengJ YfengJ force-pushed the codex/api-error-normalization branch from eb38a82 to c481dd2 Compare June 20, 2026 17:31
@YfengJ YfengJ closed this by deleting the head repository Jun 26, 2026
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.

[$40 BOUNTY] [TypeScript] Harden API response error handling

1 participant