{"record":{"id":"35570180722b3fcf","repo":"symfony/http-kernel","slug":"nested-expressions-in-validation-groups-are-not-supported","errorCode":null,"errorMessage":"Nested expressions in validation groups are not supported. Use a single Expression or a list of strings (or a GroupSequence) instead.","messagePattern":"Nested expressions in validation groups are not supported\\. Use a single Expression or a list of strings \\(or a GroupSequence\\) instead\\.","errorType":"exception","errorClass":"LogicException","httpStatus":null,"severity":"error","filePath":"Controller/ArgumentResolver/RequestPayloadValueResolver.php","lineNumber":345,"sourceCode":"    }\n\n    private function resolveValidationGroups(Expression|string|GroupSequence|\\Closure|array|null $validationGroups, ControllerArgumentsEvent $event): string|GroupSequence|array|null\n    {\n        if ($validationGroups instanceof Expression || $validationGroups instanceof \\Closure) {\n            $validationGroups = $event->evaluate($validationGroups, $this->expressionLanguage);\n        }\n\n        if (null === $validationGroups || \\is_string($validationGroups) || $validationGroups instanceof GroupSequence) {\n            return $validationGroups;\n        }\n\n        if (!\\is_array($validationGroups)) {\n            throw new \\LogicException('The validation groups expression or closure must return a string, an array of strings, or a GroupSequence.');\n        }\n\n        foreach ($validationGroups as $group) {\n            if ($group instanceof Expression) {\n                throw new \\LogicException('Nested expressions in validation groups are not supported. Use a single Expression or a list of strings (or a GroupSequence) instead.');\n            }\n\n            if ($group instanceof \\Closure) {\n                throw new \\LogicException('Nested closures in validation groups are not supported. Use a single Closure or a list of strings (or a GroupSequence) instead.');\n            }\n\n            if ($group instanceof GroupSequence) {\n                throw new \\LogicException('GroupSequence cannot be used inside an array of validation groups. Pass the GroupSequence as the top-level validationGroups value instead.');\n            }\n\n            if (!\\is_string($group)) {\n                throw new \\LogicException('Validation groups must be strings.');\n            }\n        }\n\n        return $validationGroups;\n    }\n","sourceCodeStart":327,"sourceCodeEnd":363,"githubUrl":"https://github.com/symfony/http-kernel/blob/aa3a39d7286a62cdfea98f0e69c651a3da6e36cf/Controller/ArgumentResolver/RequestPayloadValueResolver.php#L327-L363","documentation":"When validationGroups resolves to an array, each element must be a plain string group (or the top-level value may be a GroupSequence). If any array element is itself an Expression object, Symfony throws this LogicException because nested expressions are unsupported inside group arrays.","triggerScenarios":"Returning [new Expression('...')] or mixing an Expression into an array of validation groups in a #[MapRequestPayload(validationGroups: ...)] attribute.","commonSituations":"Developers attempt per-element dynamic groups by embedding Expressions in arrays instead of using a single expression or a closure returning strings.","solutions":["Use a single top-level Expression instead of nesting it in an array","Return only strings from the closure/expression","Use a GroupSequence at the top level for sequential group evaluation"],"exampleFix":"// before\nvalidationGroups: [new Expression(\"'Default'\")]\n// after\nvalidationGroups: \"'Default'\"","handlingStrategy":"validation","validationCode":"foreach ($groups as $g) { if ($g instanceof Expression) { throw new \\InvalidArgumentException('no nested expressions'); } }","typeGuard":"!($group instanceof \\Symfony\\Component\\Validator\\Constraints\\Expression)","tryCatchPattern":"try { $response = $kernel->handle($request); } catch (\\LogicException $e) { if (str_contains($e->getMessage(), 'Nested expressions')) { /* flatten expression */ } throw $e; }","preventionTips":["Only use a single top-level Expression for validationGroups","Keep group arrays string-only","Code-review attribute usages for nested callables"],"tags":["symfony","validation","expression","groups"],"backgroundTag":"unsupported-operation","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"}