fix: an array parameter with a bad element is refused, not a 500 - #938
Merged
blaipr merged 1 commit intoSep 24, 2026
Merged
Conversation
Filter::getArray() picked a filter per element with is_numeric() and passed the element on, but under strict types getInt() accepts only int|string and getString() only ?string. So a bool, a float, a nested array or an object threw a TypeError that nothing caught, and the API's catch-all answered it as a 500 with the class, the method and the server's absolute path in the body — the leak the scalar readers were already fixed to refuse with a 400. getParamArray() checked is_array() and never looked inside. Both doors reach it: the API through getParamArray(), and the web through Request::analyzeArray(), which reads via InputBag::all() and so skips Symfony's own scalar check — a form field named x[a][] makes one element an array. Filter::getArray() now decides by type and answers an element it cannot represent as null, at the point both doors share; and getParamArray() also checks the elements and refuses a bad one with the same 'Wrong parameters' 400 as the scalar readers, so the API keeps its documented contract rather than silently dropping what a caller sent.
blaipr
deleted the
fix/an-array-parameter-with-a-bad-element-is-refused-cleanly
branch
September 24, 2026 13:25
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.
Filter::getArray()picked a filter per element withis_numeric()and handed the element straighton. Under strict types
getInt()accepts onlyint|stringandgetString()only?string, so abool, a float, a nested array or an object threw a
TypeError:Nothing caught it, and the API's catch-all answers a
TypeErroras a 500 with the class, themethod and the server's absolute path in the body — the leak that
getParamInt(),getParamString()andgetParamRaw()were already fixed to refuse with a 400.getParamArray()wasthe one reader
ParameterTypesTestcalled "always right". It was right about the container(
is_array()) and never looked inside it.Both doors reach it
getParamArray()→Filter::getArray(). Sending{"tagsId": [true]}to account createwas enough.
Request::analyzeArray()→Filter::getArray(). It reads throughInputBag::all(),which skips Symfony's own scalar check, so a form field named
other_users_view[x][]makes oneelement an array from an ordinary authenticated submission.
The change, in both places it belongs
Filter::getArray()decides by type rather than byis_numeric()alone, and answers anelement it cannot represent as
null, the same as a missing one. This is the shared point bothdoors meet, so neither can 500 from it again.
Api::getParamArray()also checks the elements, and refuses a bad one with the sameWrong parameters400 as the scalar readers — so the API keeps its documented contract ratherthan silently dropping what a caller sent.
Tests
FilterTestis new —Filterhad no unit test at all. A bool, a float, a nested array and anobject each come back as
null; ids and text still come through.ParameterTypesTestgainsanArrayParameterWithABadElementIsRefusedover the same four shapes,plus a good id beside a bad one.
Mutation-verified in both directions: reverting
src/fails all fourFilterTestcases with theTypeError, and all four API cases with a non-400.