fix(frontend): prevent ApiError [object Object] from FastAPI 422 detail#13498
Open
seer-by-sentry[bot] wants to merge 1 commit into
Open
fix(frontend): prevent ApiError [object Object] from FastAPI 422 detail#13498seer-by-sentry[bot] wants to merge 1 commit into
seer-by-sentry[bot] wants to merge 1 commit into
Conversation
Contributor
|
This PR targets the Automatically setting the base branch to |
Codecov Report❌ Patch coverage is ❌ 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
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why / What / How
Previously, when the backend (FastAPI) returned a 422 validation error, the
customMutatorin the frontend would attempt to use thedetailfield directly as the error message. FastAPI's 422detailis an an array of validation error objects (e.g.,[{loc: [...], msg: "field required", type: "value_error.missing"}]). BecausecustomMutatordid 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.tsto correctly parse and display FastAPI 422 validation errors, ensuring that clear and informative messages are shown to the user.This fix modifies
customMutator.tsto:responseData.detailis an array.msgfield and join them into a single, human-readable string (e.g.,"field required; value is not a valid integer").detailvalues, fall back toJSON.stringifyto ensure a meaningful representation.Changes 🏗️
customMutator.tsto handle array-baseddetailfields in 422 validation errors.msgfields from validation error objects within thedetailarray and concatenate them.JSON.stringifyfor non-string, non-arraydetailvalues.Checklist 📋
For code changes:
Example test plan
For configuration changes:
.env.defaultis updated or already compatible with my changesdocker-compose.ymlis updated or already compatible with my changesExamples of configuration changes
Fixes BUILDER-3ZE
Fixes SENTRY-128