fix(sof-server): malformed inline ViewDefinition answers the documented 422 - #742
Merged
Conversation
… 400 Closes #670. parse_parameters strictly deserializes the whole Parameters wrapper, so a type mismatch inside an inline ViewDefinition failed at the wrapper stage and took the wrapper's 400 - the documented 422 path (audit item 9) only fired for the bare-ViewDefinition body shortcut. On a wrapper deserialization failure the handler now probes the raw JSON for inline ViewDefinitions and lets the first one that fails its own parse speak with the 422-mapped error; a wrapper malformed anywhere else keeps its 400. The version arms deserialize from a borrowed Value so the happy path stays clone-free. Un-quarantines test_invalid_view_definition_returns_422.
smunini
approved these changes
Aug 27, 2026
smunini
approved these changes
Aug 27, 2026
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
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 #670.
parse_parametersstrictly deserializes the wholeParameterswrapper in one pass, so a type mismatch inside an inline ViewDefinition (select: "not-an-array") failed at the wrapper stage and answered the wrapper's400— the documented422path (audit item #9) only ever fired for the bare-ViewDefinition body shortcut.Exactly the fix direction the issue sketched: on a wrapper deserialization failure, the handler probes the raw JSON for inline ViewDefinitions (
parameter[].resource.resourceType == "ViewDefinition") and lets the first one that fails its own parse speak, with the 422-mappedInvalidViewDefinitionerror. A wrapper that is malformed anywhere else keeps its 400 untouched. The four version arms now deserialize from a borrowedValue(Parameters::deserialize(&json)), so the happy path pays no clone for the probe's sake.test_invalid_view_definition_returns_422comes out of#[ignore]quarantine and passes against the real router; the fullhelios-sofsuite is green.