{"record":{"id":"79499d17f213a3a1","repo":"symfony/http-kernel","slug":"the-action-argument-1-s-is-required-to-be-an-array-the","errorCode":null,"errorMessage":"The action argument \"...$%1$s\" is required to be an array, the request attribute \"%1$s\" contains a type of \"%2$s\" instead.","messagePattern":"The action argument \"\\.\\.\\.\\$%1\\$s\" is required to be an array, the request attribute \"%1\\$s\" contains a type of \"%2\\$s\" instead\\.","errorType":"exception","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"Controller/ArgumentResolver/VariadicValueResolver.php","lineNumber":34,"sourceCode":"use Symfony\\Component\\HttpKernel\\ControllerMetadata\\ArgumentMetadata;\n\n/**\n * Yields a variadic argument's values from the request attributes.\n *\n * @author Iltar van der Berg <kjarli@gmail.com>\n */\nfinal class VariadicValueResolver implements ValueResolverInterface\n{\n    public function resolve(Request $request, ArgumentMetadata $argument): array\n    {\n        if (!$argument->isVariadic() || !$request->attributes->has($argument->getName())) {\n            return [];\n        }\n\n        $values = $request->attributes->get($argument->getName());\n\n        if (!\\is_array($values)) {\n            throw new \\InvalidArgumentException(\\sprintf('The action argument \"...$%1$s\" is required to be an array, the request attribute \"%1$s\" contains a type of \"%2$s\" instead.', $argument->getName(), get_debug_type($values)));\n        }\n\n        return $values;\n    }\n}\n","sourceCodeStart":16,"sourceCodeEnd":40,"githubUrl":"https://github.com/symfony/http-kernel/blob/aa3a39d7286a62cdfea98f0e69c651a3da6e36cf/Controller/ArgumentResolver/VariadicValueResolver.php#L16-L40","documentation":"VariadicValueResolver fetches the request attribute named after the variadic controller argument and requires it to be an array. If the attribute exists but holds a scalar/object, this InvalidArgumentException is thrown because ...$arg can only consume array values.","triggerScenarios":"A route/controller sets a request attribute (e.g. via a listener or _controller_defaults) with a scalar value whose name collides with a variadic action argument, e.g. public function foo(...$ids) while attributes->get('ids') is a string.","commonSituations":"Route default values being strings while the action declares ...$param, or custom listeners setting single values under the same key.","solutions":["Ensure the request attribute value is an array (wrap scalars in an array)","Rename the variadic argument to avoid attribute-name collisions","Cast route defaults to arrays when defining the route"],"exampleFix":"// before\n$attributes->set('ids', '1');\n// after\n$attributes->set('ids', ['1']);","handlingStrategy":"type-guard","validationCode":"$values = $request->attributes->get($name); if (null !== $values && !is_array($values)) { throw new \\InvalidArgumentException(\"$name attribute must be array\"); }","typeGuard":"is_array($request->attributes->get($argumentName))","tryCatchPattern":"try { $response = $kernel->handle($request); } catch (\\InvalidArgumentException $e) { if (str_contains($e->getMessage(), 'required to be an array')) { /* fix attribute value */ } throw $e; }","preventionTips":["Keep request attribute values arrays when names match variadic args","Avoid route defaults that shadow variadic parameter names","Type-guard attributes in listeners before dispatch"],"tags":["symfony","variadic","argument-resolver","type-error"],"backgroundTag":"type-mismatch","analyzedSha":"aa3a39d7286a62cdfea98f0e69c651a3da6e36cf","analyzedAt":"2026-09-13T18:03:36.509Z","contentChangedAt":"2026-09-13T18:03:36.509Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}