jmespath.py icon indicating copy to clipboard operation
jmespath.py copied to clipboard

Type-check extra arguments to variadic functions

Open bysiber opened this issue 9 months ago • 0 comments

_type_check only validates the first N arguments where N is the length of the function signature. For variadic functions like merge(), the signature has a single entry with variadic: True, so only the first argument is type-checked. All extra arguments bypass validation entirely.

>>> jmespath.search('merge(`{"a":1}`, `"not_a_dict"`)', {})
# Expected: JMESPathTypeError (string is not an object)
# Actual: ValueError: dictionary update sequence element #0 has length 1

The fix adds a second loop after the normal signature check that validates the extra variadic arguments against the last signature entry's type constraints.

bysiber avatar Feb 20 '26 11:02 bysiber