Skip to content

Fix frontend axios error handling#6467

Open
sahil2448 wants to merge 3 commits into
FlowiseAI:mainfrom
sahil2448:fix/frontend-axios-error-handling
Open

Fix frontend axios error handling#6467
sahil2448 wants to merge 3 commits into
FlowiseAI:mainfrom
sahil2448:fix/frontend-axios-error-handling

Conversation

@sahil2448
Copy link
Copy Markdown
Contributor

Standardize ToolDialog error handling with shared Axios-safe error extractor

Linked issue

Closes #6466


Description

This PR improves frontend API error handling by making the shared getErrorMessage utility safer for Axios-style errors and using it in ToolDialog.

Previously, ToolDialog directly accessed error.response.data inside several catch blocks. That can fail when Axios does not include a response object, such as during network failures, backend downtime, CORS issues, timeouts, or cancelled requests. In those cases, the error handler could throw another runtime error while trying to display the original API failure.


Changes made

  • Updated packages/ui/src/utils/errorHandler.js

    • Safely reads response.data.message
    • Safely reads response.data.error
    • Supports string response bodies
    • Falls back to response status/statusText when response data is unavailable
    • Keeps the existing generic fallback for normal JavaScript errors
  • Updated packages/ui/src/views/tools/ToolDialog.jsx

    • Replaced repeated direct error.response.data access with getErrorMessage(error)
    • Applied this to tool export, create, save, and delete error handlers
  • Added packages/ui/src/utils/errorHandler.test.js

    • Covers Axios response messages
    • Covers Axios error fields
    • Covers string response bodies
    • Covers status-only responses
    • Covers normal JavaScript errors without Axios response data

Why this is needed

Instead of each component manually reading nested Axios fields, the shared helper now handles the common API error shapes safely. Components can show useful error messages without risking a secondary crash inside the catch block.


Testing

Ran the focused UI test:

pnpm -C packages/ui test errorHandler.test.js --runInBand

Result:

Test Suites: 1 passed
Tests: 5 passed

Screenshots

Not applicable. This is an error-handling utility change and does not alter the normal UI layout.


Additional notes

This PR keeps the scope focused on ToolDialog and the shared error extractor. Other frontend components still contain similar inline Axios error parsing and can be migrated in follow-up PRs.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a centralized getErrorMessage utility to extract error messages from Axios responses and standard errors, replacing inline error-parsing logic in ToolDialog.jsx and adding corresponding unit tests. The review feedback suggests improving the utility by handling cases where the response message is an array of strings (e.g., validation errors from NestJS) and joining them, ensuring detailed error messages are not lost.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread packages/ui/src/utils/errorHandler.js
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@sahil2448
Copy link
Copy Markdown
Contributor Author

Hii Maintainers....please review this PR and tell me any changes if needed...!

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.

Bug : Frontend API error handling can crash when Axios error.response is missing

1 participant