Skip to content

fix(ui): preserve AxiosError in the response interceptor - #259

Merged
nazarli-shabnam merged 1 commit into
mainfrom
fix/preserve-axios-error
Jul 5, 2026
Merged

fix(ui): preserve AxiosError in the response interceptor#259
nazarli-shabnam merged 1 commit into
mainfrom
fix/preserve-axios-error

Conversation

@martian56

@martian56 martian56 commented Jul 5, 2026

Copy link
Copy Markdown
Member

Summary

Closes #136.

The global Axios response interceptor rejected with a brand-new Error(message), discarding the original AxiosError and with it response, response.status, and response.data. Call sites that branch on those fields had silently stopped working:

  • integrationService.githubGetProjectSync checks err.response.status === 404 to return null ("repo not linked yet"). With the field gone, a 404 threw instead of rendering the empty state.
  • InviteSignUpPage and several SettingsPage handlers read err.response.data.error to surface the backend's specific validation message, and always fell back to a generic "Something went wrong."

The interceptor now attaches the friendly text to error.message and rejects the original AxiosError, so error.message consumers keep the readable text while status- and body-based branches work again.

Testing

  • npm run typecheck and npm run lint pass.
  • Browser-verified against the running API: an authenticated request that 404s now rejects with an error where isAxiosError === true, response.status === 404, response.data.error is the backend message, and message is the friendly text. Before the fix the same request rejected with a bare Error (no response).

AI assistance

This change was produced with the help of Claude Code (Claude Opus 4.8). See the Co-Authored-By trailer on the commit.

Summary by CodeRabbit

  • Bug Fixes
    • Improved API error handling so failed requests now keep their original error details while showing a clearer user-facing message.
    • This helps preserve response information such as status codes and server error data for more reliable troubleshooting and UI behavior.

@martian56
martian56 requested a review from a team as a code owner July 5, 2026 09:56
@martian56 martian56 added this to the Finish w Enhancements milestone Jul 5, 2026
@martian56 martian56 added bug Something isn't working UI labels Jul 5, 2026
@martian56 martian56 self-assigned this Jul 5, 2026
@strix-security

strix-security Bot commented Jul 5, 2026

Copy link
Copy Markdown

Strix Security Review

No security issues found.

Updated for a2ad9f8.


Reviewed by Strix
Re-run review · Configure security review settings

@coderabbitai

coderabbitai Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 703b3362-8b8d-48a0-a9a5-e3b39a177664

📥 Commits

Reviewing files that changed from the base of the PR and between 371e811 and a2ad9f8.

📒 Files selected for processing (1)
  • apps/web/src/api/client.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/web/src/api/client.ts

📝 Walkthrough

Walkthrough

The Axios response error interceptor in the API client was modified to preserve the original AxiosError instance. Instead of rejecting a newly constructed Error object, it now mutates the message field on the existing error and rejects that same instance, retaining fields like response and status.

Changes

Axios Error Preservation

Layer / File(s) Summary
Preserve AxiosError in response interceptor
apps/web/src/api/client.ts
The response interceptor now sets error.message via getApiErrorMessage(error) and rejects the original AxiosError instance instead of a newly created Error, preserving response and status fields.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Poem

A rabbit hopped through axios code,
Found errors dropped along the road,
Now status codes still ride along,
The original error stays strong,
Hop, hop, hooray—no fields are lost! 🐇

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description covers summary and testing, but omits several required template sections like type, surface, and checklist. Fill in the missing template sections, especially Type of change, Surface, What changed, Why this approach, and the checklist.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is specific, concise, and accurately reflects the main change.
Linked Issues check ✅ Passed The change preserves the original AxiosError while updating message text, so the 404 and response-data branches should work again.
Out of Scope Changes check ✅ Passed The diff appears narrowly scoped to the Axios interceptor fix with no unrelated code changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/preserve-axios-error

Comment @coderabbitai help to get the list of available commands.

The global response interceptor rejected with a fresh Error(message),
throwing away the original AxiosError and with it response, status, and
data. Call sites that branch on those fields silently stopped working:
GitHub sync errored instead of showing the not-linked empty state, and
several forms fell back to a generic message instead of the backend's
specific one. Attach the friendly text to error.message and reject the
original error so status- and body-based handling keeps working.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@martian56
martian56 force-pushed the fix/preserve-axios-error branch from 371e811 to a2ad9f8 Compare July 5, 2026 10:01
@nazarli-shabnam
nazarli-shabnam merged commit 2fb625c into main Jul 5, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Axios response interceptor discards AxiosError, breaking status-based error handling

2 participants