{"record":{"id":"0e6dc49d24003d94","repo":"passbolt/passbolt_api","slug":"0-is-not-a-valid-parent-filter","errorCode":null,"errorMessage":"\"{0}\" is not a valid parent filter.","messagePattern":"\"(.+?)\" is not a valid parent filter\\.","errorType":"validation","errorClass":"CakeException","httpStatus":400,"severity":"error","filePath":"src/Controller/Component/QueryStringComponent.php","lineNumber":537,"sourceCode":"        return true;\n    }\n\n    /**\n     * Validate a filter that is an array of parent id\n     * Examples:\n     * - Bueno: [0 => '98c2bef5-cd5f-59e7-a1a7-0107c9a7cf08']\n     * - No Bueno: ['this' => 'no']\n     *\n     * @param array $values array of group id to check\n     * @param string|bool $filtername for error message display\n     * @throw Exception if the filter is not valid\n     * @return bool true if validate\n     */\n    public static function validateFilterParentFolders(array $values, string|bool $filtername)\n    {\n        foreach ($values as $i => $parentId) {\n            if (!is_int($i)) {\n                throw new CakeException(__('\"{0}\" is not a valid parent filter.', $i, $filtername));\n            }\n            if (!is_string($parentId) && $parentId !== false) {\n                throw new CakeException(__('\"{0}\" is not a valid parent filter.', $i));\n            }\n            self::validateFilterParentFolder($parentId, $filtername);\n        }\n\n        return true;\n    }\n\n    /**\n     * Validate a filter that is a single resource id\n     * Examples:\n     * - Bueno: '98c2bef5-cd5f-59e7-a1a7-0107c9a7cf08'\n     * - No Bueno: 'no-bueno'\n     *\n     * @param array $values resources id\n     * @param string $filterName name of filters","sourceCodeStart":519,"sourceCodeEnd":555,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/src/Controller/Component/QueryStringComponent.php#L519-L555","documentation":"Thrown by QueryStringComponent::validateFilterParentFolders when the key of an entry in a parent-folder filter array is not an integer. Like the other list filters, parent filters must be numerically indexed non-assoc arrays. The message interpolates the offending key.","triggerScenarios":"Passing an associative array such as ['folder' => $id] or ['this' => 'no'] to validateFilterParentFolders, e.g. via ?filter[has-parent][folder]=<uuid> instead of ?filter[has-parent][]=<uuid> (or =false).","commonSituations":"Client constructs the filter as a map instead of a list; URL query syntax mistake; reused assoc option arrays from other API calls.","solutions":["Use list syntax: filter[has-parent][]=<uuid> (or []=false for root).","Reindex input with array_values($values) before validation.","Reject or normalize assoc filter input at the client boundary."],"exampleFix":"// before\nGET /folders?filter[has-parent][folder]=98c2bef5-cd5f-59e7-a1a7-0107c9a7cf08\n// after\nGET /folders?filter[has-parent][]=98c2bef5-cd5f-59e7-a1a7-0107c9a7cf08","handlingStrategy":"validation","validationCode":"if (!is_array($values)) { throw new \\InvalidArgumentException('Filter must be an array.'); }\nforeach (array_keys($values) as $k) {\n    if (!is_int($k)) {\n        throw new \\InvalidArgumentException('Parent filter keys must be integers; use filter[has-parent][]= syntax.');\n    }\n}","typeGuard":"function isIntKeyedList(mixed $values): bool {\n    return is_array($values) && $values === array_values($values);\n}","tryCatchPattern":"try {\n    $ok = QueryStringComponent::validateFilterParentFolders($values, $filterName);\n} catch (\\Cake\\Core\\Exception\\CakeException $e) {\n    throw new BadRequestException($e->getMessage());\n}","preventionTips":["Always use filter[has-parent][]= list syntax for parent-folder filters.","Reindex arrays with array_values() before sending.","Cover filter serialization with integration tests."],"tags":["validation","query-string","filter","array-shape"],"backgroundTag":"invalid-argument-format","analyzedSha":"31c1bbc10f32808a607fa9bd81891e898779c0bc","analyzedAt":"2026-09-17T00:04:38.960Z","contentChangedAt":"2026-09-17T00:04:38.960Z","schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}