{"record":{"id":"7e050979de24e7d9","repo":"symfony/http-kernel","slug":"groupsequence-cannot-be-used-inside-an-array-of-validation","errorCode":null,"errorMessage":"GroupSequence cannot be used inside an array of validation groups. Pass the GroupSequence as the top-level validationGroups value instead.","messagePattern":"GroupSequence cannot be used inside an array of validation groups\\. Pass the GroupSequence as the top-level validationGroups value instead\\.","errorType":"exception","errorClass":"LogicException","httpStatus":null,"severity":"error","filePath":"Controller/ArgumentResolver/RequestPayloadValueResolver.php","lineNumber":353,"sourceCode":"        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\n    private static function hasNonStringScalar(array $data): bool\n    {\n        $stack = [$data];\n\n        while ($stack) {\n            foreach (array_pop($stack) as $v) {\n                if (\\is_array($v)) {\n                    $stack[] = $v;","sourceCodeStart":335,"sourceCodeEnd":371,"githubUrl":"https://github.com/symfony/http-kernel/blob/aa3a39d7286a62cdfea98f0e69c651a3da6e36cf/Controller/ArgumentResolver/RequestPayloadValueResolver.php#L335-L371","documentation":"A GroupSequence is only accepted as the entire top-level validationGroups value. If a GroupSequence instance appears as an element inside an array of groups, Symfony throws this LogicException directing you to pass it at the top level.","triggerScenarios":"Passing validationGroups: [new GroupSequence([...]), 'Other'] on #[MapRequestPayload] or #[MapQueryString].","commonSituations":"Trying to combine a sequence with additional standalone groups in one array — the resolver's contract only permits a top-level sequence or a flat string array.","solutions":["Pass the GroupSequence directly as validationGroups (not inside an array)","Fold the extra groups into the sequence itself","Use GroupSequenceProvider on the DTO if dynamic sequencing is needed"],"exampleFix":"// before\nvalidationGroups: [new GroupSequence(['A','B'])]\n// after\nvalidationGroups: new GroupSequence(['A','B'])","handlingStrategy":"validation","validationCode":"foreach ($groups as $g) { if ($g instanceof GroupSequence) { throw new \\InvalidArgumentException('sequence must be top-level'); } }","typeGuard":"$groups instanceof GroupSequence || (is_array($groups) && !in_array(false, array_map('is_string', $groups), true))","tryCatchPattern":"try { $response = $kernel->handle($request); } catch (\\LogicException $e) { if (str_contains($e->getMessage(), 'GroupSequence cannot be used inside')) { /* move sequence to top level */ } throw $e; }","preventionTips":["Pass GroupSequence directly, never inside arrays","Fold extra groups into the sequence","Review attribute configs in CI"],"tags":["symfony","validation","group-sequence","groups"],"backgroundTag":"invalid-argument-value","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"}