Map server-side validation errors onto profile edit form (#238)#320
Merged
Lakes41 merged 1 commit intoJul 24, 2026
Conversation
- Adds mapServerValidationErrors() to lib/validation/profile.ts, translating a 422 ApiError's field-level details (snake_case or camelCase) onto the same ProfileValidationErrors shape used by client-side validateProfile - Also handles ProfileValidationError instances directly - Wires it into ProfileEditor's mutation onError so server rejections render inline on the same fields as client-side errors, instead of only a generic rollback message - Adds test/profile-server-error-mapping.test.ts covering valid submission, client-side invalid submission, live-backend 422 (both key casings), unrecognized detail keys, non-validation errors, and missing details Closes Adamantine-guild#238
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.
Closes #238
Summary
Client-side validation (
validateProfileinlib/validation/profile.ts) already existed onmain. This PR closes the remaining gap: server-side validation errors from a failedupdateProfilecall weren't rendered inline — only as a generic rollback message.Changes
mapServerValidationErrors()inlib/validation/profile.tsmaps a 422ApiError's field-leveldetails(snake_case or camelCase keys) onto the sameProfileValidationErrorsshape used by client-side validation. Also handlesProfileValidationErrorinstances directly.ProfileEditor's mutationonErrornow calls this and sets inline field errors when present, alongside the existing rollback message.Testing
test/profile-server-error-mapping.test.ts— 7 new tests: valid submission, client-side invalid submission, live-backend 422 with snake_case details, live-backend 422 with camelCase details, unrecognized detail keys, non-validation errors (network/auth), and a validation_error with no details.Full suite: 491/491 passing, clean typecheck.
Acceptance criteria