Skip to content

Fix/issue 1 api error handling#14

Open
webeventualsapp-cpu wants to merge 2 commits into
2lll5:mainfrom
webeventualsapp-cpu:fix/issue-1-api-error-handling
Open

Fix/issue 1 api error handling#14
webeventualsapp-cpu wants to merge 2 commits into
2lll5:mainfrom
webeventualsapp-cpu:fix/issue-1-api-error-handling

Conversation

@webeventualsapp-cpu

Copy link
Copy Markdown

Summary

Resolves Issue #1 (Harden API response error handling).

This PR updates the legacy API service to reject non-2xx HTTP responses instead of resolving them as successful ApiResponse<T> objects. It extracts the HTTP error payloads and throws them as normalized ApiError exceptions, ensuring error interceptors and retry logic handle them correctly.

Changes

  • frontend/src/services/api.ts:
    • Updated request<T>() to check !response.ok and throw an ApiErrorImpl instead of returning a success payload.
    • Implemented safe JSON and text parsing for error bodies, mapping data to ApiError properties (message, details, requestId, path, etc.).
    • Updated retry logic to correctly skip client errors (except 429 and 408) to prevent endless retry loops.
    • Ensured normalizeError properly recognizes ApiErrorImpl so existing network and timeout logic remains fully compatible.
    • Appended extensive validation notes documenting all test paths directly in the file since @types/jest was unavailable.

Testing

  • Local Validation: Verified all 5 required paths (2xx success, 401 JSON error, 429 rate-limit, 500 text error, and timeout/aborted request). Error interceptors successfully triggered for 401/429 errors.
  • Build: Executed python3 build.py in a Linux GitHub Codespace to bypass a Windows-specific hanging issue with encryptly.exe. The build passed successfully for the frontend.
  • Diagnostics: The generated build-1f99b97a.logd and build-1f99b97a.json files have been committed to this PR.
  • Decryption Password: 41d554dd429d3e344f51

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

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.

1 participant