Skip to content

fix(frontend): prevent ApiError [object Object] from FastAPI 422 detail#13498

Open
seer-by-sentry[bot] wants to merge 1 commit into
devfrom
seer/fix/fastapi-422-detail-message
Open

fix(frontend): prevent ApiError [object Object] from FastAPI 422 detail#13498
seer-by-sentry[bot] wants to merge 1 commit into
devfrom
seer/fix/fastapi-422-detail-message

Conversation

@seer-by-sentry

@seer-by-sentry seer-by-sentry Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Why / What / How

Previously, when the backend (FastAPI) returned a 422 validation error, the customMutator in the frontend would attempt to use the detail field directly as the error message. FastAPI's 422 detail is an an array of validation error objects (e.g., [{loc: [...], msg: "field required", type: "value_error.missing"}]). Because customMutator did not explicitly handle this array, JavaScript's implicit string coercion converted it to the generic "[object Object]", leading to unhelpful error messages for users.

This PR modifies customMutator.ts to correctly parse and display FastAPI 422 validation errors, ensuring that clear and informative messages are shown to the user.

This fix modifies customMutator.ts to:

  • Check if responseData.detail is an array.
  • If it is an array, map each item to its msg field and join them into a single, human-readable string (e.g., "field required; value is not a valid integer").
  • For other non-string, non-array detail values, fall back to JSON.stringify to ensure a meaningful representation.

Changes 🏗️

  • Modified customMutator.ts to handle array-based detail fields in 422 validation errors.
  • Implemented logic to extract msg fields from validation error objects within the detail array and concatenate them.
  • Added a fallback to JSON.stringify for non-string, non-array detail values.

Checklist 📋

For code changes:

  • I have clearly listed my changes in the PR description
  • I have made a test plan
  • I have tested my changes according to the test plan:
    • ...
Example test plan
  • Create from scratch and execute an agent with at least 3 blocks
  • Import an agent from file upload, and confirm it executes correctly
  • Upload agent to marketplace
  • Import an agent from marketplace and confirm it executes correctly
  • Edit an agent from monitor, and confirm it executes correctly

For configuration changes:

  • .env.default is updated or already compatible with my changes
  • docker-compose.yml is updated or already compatible with my changes
  • I have included a list of my configuration changes in the PR description (under Changes)
Examples of configuration changes
  • Changing ports
  • Adding new services that need to communicate with each other
  • Secrets or environment variable changes
  • New or infrastructure changes such as databases

Fixes BUILDER-3ZE
Fixes SENTRY-128

@seer-by-sentry seer-by-sentry Bot requested a review from a team as a code owner July 7, 2026 16:18
@seer-by-sentry seer-by-sentry Bot requested review from Bentlybro and kcze and removed request for a team July 7, 2026 16:18
@github-project-automation github-project-automation Bot moved this to 🆕 Needs initial review in AutoGPT development kanban Jul 7, 2026
@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

This PR targets the master branch but does not come from dev or a hotfix/* branch.

Automatically setting the base branch to dev.

@github-actions github-actions Bot changed the base branch from master to dev July 7, 2026 16:18
@github-actions github-actions Bot added the platform/frontend AutoGPT Platform - Front end label Jul 7, 2026
@github-actions github-actions Bot added the size/m label Jul 7, 2026
@codecov

codecov Bot commented Jul 7, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 60.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.68%. Comparing base (e2711b1) to head (c8314cb).
⚠️ Report is 37 commits behind head on dev.

❌ Your patch check has failed because the patch coverage (60.00%) is below the target coverage (70.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev   #13498      +/-   ##
==========================================
- Coverage   74.71%   74.68%   -0.04%     
==========================================
  Files        2537     2537              
  Lines      192315   192313       -2     
  Branches    18925    18927       +2     
==========================================
- Hits       143697   143620      -77     
- Misses      44493    44556      +63     
- Partials     4125     4137      +12     
Flag Coverage Δ
platform-frontend 43.02% <60.00%> (-0.04%) ⬇️
platform-frontend-e2e 31.72% <50.00%> (-0.66%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
Platform Backend 81.98% <ø> (ø)
Platform Frontend 47.31% <60.00%> (-0.23%) ⬇️
AutoGPT Libs ∅ <ø> (∅)
Classic AutoGPT 28.43% <ø> (ø)
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

platform/frontend AutoGPT Platform - Front end size/m

Projects

Status: 🆕 Needs initial review
Status: No status

Development

Successfully merging this pull request may close these issues.

0 participants