fix: improve error messaging when saving custom field#7578
Conversation
Replace the generic "Failed to save custom field" toast with a phase-aware message that distinguishes a failure to create the MetadataField from a failure to bind it to a content type. When the field was created but the binding call failed (e.g. 403 for non-admin project administrators, see #7424), tell the user the field is orphaned and needs an organisation administrator to finish or remove it. Other errors now bubble up the backend detail string instead of being swallowed. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Docker builds report
|
There was a problem hiding this comment.
Code Review
This pull request enhances error handling in the CreateMetadataField component by introducing logic to extract specific error details from API responses and providing context-aware messages for different failure phases, such as field creation versus binding. A review comment identifies that the current error extraction logic is too restrictive and suggests a more robust implementation to handle various backend error formats, such as those from Django Rest Framework, to ensure users receive informative feedback.
Visual RegressionNo baseline found — first run. Baselines will be generated after merge to main. |
Address review feedback on #7578: getErrorDetail now extracts messages from DRF field-error objects, non_field_errors arrays, raw string errors, and network failures with message/error properties. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Drop the custom getErrorDetail/buildErrorMessage parsers in favour of the existing <ErrorMessage> component, which already handles DRF detail, non_field_errors, field-error objects and Error instances. Store the caught error in state and render it inline, with a separate warning banner when a successful create was followed by a binding failure (the orphaned-field case from #7424). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
When a custom field create succeeds but the binding call fails, show only the orphan-explanation message rather than stacking it above the generic permission error. The orphan message already covers the user's next step. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
talissoncosta
left a comment
There was a problem hiding this comment.
LGTM. Thanks for handling that @kyle-ssg !
Thanks for submitting a PR! Please check the boxes below:
Changes
Contributes to #7424
This PR improves the error messaging for creating metadata fields.
How did you test this code?