fix: return 4xx instead of 5xx for MRF V4 field validation errors#9788
Merged
Conversation
scottheng96
marked this pull request as ready for review
July 23, 2026 09:34
|
Tick the box to add this pull request to the merge queue (same as
|
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.
Problem
Field-level validation failures on the multirespondent (MRF) V4 submission path return a 500 Internal Server Error instead of a 400. For example, when a respondent submits a dropdown option that no longer exists on the form (stale form definition — admin edited options after the respondent loaded the form),
DropdownValidatorV4correctly rejects the answer, but the respondent sees the generic "Something went wrong. Please try again." message instead of the "check your responses and try again" hint that would tell them to refresh.This also pollutes 5xx alarms with what is really respondent error, and each occurrence logs a spurious "Unknown route error observed".
Root cause:
mapRouteErrorinsubmission.utils.tsmaps errors to HTTP statuses by error class.ValidateFieldError(V1) andValidateFieldErrorV3are mapped to 400, butValidateFieldErrorV4— introduced with the V4 BE handling (#9785) — was never added to that case group, so it falls through to thedefaultbranch and returns 500. (Thestatus = 400baked into theValidateFieldErrorV4constructor is never read by the mapper.)Solution
Add
ValidateFieldErrorV4to the existing 400 case group inmapRouteError, alongsideValidateFieldErrorandValidateFieldErrorV3. V4 validation failures now return the same 400 response and user-facing message ("There is something wrong with your form submission. Please check your responses and try again...") as the V1/V3 paths.Breaking Changes
Tests
TC1: V4 field validation failure returns 400
Invalid answer: DropdownValidatorV4: answer is not a valid dropdown optionbut no longer logsUnknown route error observedTC2: Regression — valid MRF submission still succeeds
🤖 Generated with Claude Code