Skip to content

fix(sof-server): malformed inline ViewDefinition answers the documented 422 - #742

Merged
smunini merged 1 commit into
mainfrom
fix/670-inline-vd-422
Aug 28, 2026
Merged

fix(sof-server): malformed inline ViewDefinition answers the documented 422#742
smunini merged 1 commit into
mainfrom
fix/670-inline-vd-422

Conversation

@angela-helios

Copy link
Copy Markdown
Contributor

Closes #670.

parse_parameters strictly deserializes the whole Parameters wrapper in one pass, so a type mismatch inside an inline ViewDefinition (select: "not-an-array") failed at the wrapper stage and answered the wrapper's 400 — the documented 422 path (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-mapped InvalidViewDefinition error. A wrapper that is malformed anywhere else keeps its 400 untouched. The four version arms now deserialize from a borrowed Value (Parameters::deserialize(&json)), so the happy path pays no clone for the probe's sake.

test_invalid_view_definition_returns_422 comes out of #[ignore] quarantine and passes against the real router; the full helios-sof suite is green.

… 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.
@codecov

codecov Bot commented Aug 27, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.66667% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
crates/sof/src/handlers.rs 91.66% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@smunini
smunini merged commit bdd5b9c into main Aug 28, 2026
21 checks passed
@smunini
smunini deleted the fix/670-inline-vd-422 branch August 28, 2026 00:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sof-server: malformed inline ViewDefinition in Parameters returns 400 instead of the documented 422

2 participants