symfony/http-kernel · error · LogicException
Mapping variadic argument "$
Error message
Mapping variadic argument "$%s" is not supported.
What it means
Symfony throws this LogicException from RequestPayloadValueResolver when a controller argument annotated with #[MapQueryString] (or another non-MapRequestPayload payload attribute) is declared variadic (...$arg). Variadic mapping is only meaningful for MapRequestPayload, so any other payload-mapping attribute on a variadic argument is rejected at resolve time.
Solutions
- Remove the variadic (...) declaration from the argument
- Use a single typed argument (e.g. an array-backed DTO) instead of variadic
- Switch to #[MapRequestPayload] with type set if you actually need an array of mapped objects
Example fix
// before
public function index(#[MapQueryString] Query ...$filters) {}
// after
public function index(#[MapQueryString] QueryFilterList $filters) {} Defensive patterns
Strategy: validation
Validate before calling
foreach ($reflParams as $p) { if ($p->isVariadic() && $p->getAttributes(MapQueryString::class)) { throw new \LogicException($p->name.' must not be variadic'); } } Type guard
if (!$param->isVariadic()) { /* safe to map */ } Try / catch
try { $kernel->handle($request); } catch (\LogicException $e) { if (str_contains($e->getMessage(), 'variadic')) { /* fix controller signature */ } throw $e; } Prevention
- Never combine variadic arguments with payload-mapping attributes
- Use DTO collections or MapRequestPayload arrays for repeated payloads
- Static-analyze controller signatures in CI
When it happens
Trigger: Declaring a controller action argument like #[MapQueryString] ...$filters, or any variadic argument carrying a payload attribute other than MapRequestPayload, then dispatching a request to that action.
Common situations: Developers try to map multiple query-string segments or repeated payload objects to a variadic parameter, assuming the resolver fans out; the resolver does not support that shape for query string or headers.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- Request payload contains invalid "form" data.
- Could not resolve the "$
- The validation groups expression or closure must return a…
- The action argument "...$%1$s" is required to be an array…
- Argument $ does not have a default value. Use "…
AI-assisted analysis of symfony/http-kernel@aa3a39d728 (2026-09-13).
Data as JSON: /api/errors/ecf115ab25d19f49.
Report an issue: GitHub.
Appendix: source
Thrown at Controller/ArgumentResolver/RequestPayloadValueResolver.php:91
private readonly ?TranslatorInterface $translator = null,
private string $translationDomain = 'validators',
private ?ExpressionLanguage $expressionLanguage = null,
) {
}
public function resolve(Request $request, ArgumentMetadata $argument): iterable
{
$attribute = $argument->getAttributesOfType(MapQueryString::class, ArgumentMetadata::IS_INSTANCEOF)[0]
?? $argument->getAttributesOfType(MapRequestPayload::class, ArgumentMetadata::IS_INSTANCEOF)[0]
?? $argument->getAttributesOfType(MapUploadedFile::class, ArgumentMetadata::IS_INSTANCEOF)[0]
?? null;
if (!$attribute) {
return [];
}
if ($attribute instanceof MapQueryString && $argument->isVariadic()) {
throw new \LogicException(\sprintf('Mapping variadic argument "$%s" is not supported.', $argument->getName()));
}
if ($attribute instanceof MapRequestPayload) {
if ('array' === $argument->getType()) {
if (!$attribute->type) {
throw new NearMissValueResolverException(\sprintf('Please set the $type argument of the #[%s] attribute to the type of the objects in the expected array.', MapRequestPayload::class));
}
} elseif ($attribute->type && !$argument->isVariadic()) {
throw new NearMissValueResolverException(\sprintf('Please set its type to "array" when using argument $type of #[%s].', MapRequestPayload::class));
}
}
$attribute->metadata = $argument;
return [$attribute];
}
public function onKernelControllerArguments(ControllerArgumentsEvent $event): voidView on GitHub (pinned to aa3a39d728)