{"record":{"id":"17d98014ce7d183c","repo":"passbolt/passbolt_api","slug":"0-is-not-a-valid-resource-id-for-filter-1","errorCode":null,"errorMessage":"\"{0}\" is not a valid resource id for filter {1}.","messagePattern":"\"(.+?)\" is not a valid resource id for filter (.+?)\\.","errorType":"validation","errorClass":"CakeException","httpStatus":400,"severity":"error","filePath":"src/Controller/Component/QueryStringComponent.php","lineNumber":563,"sourceCode":"        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\n     * @throw CakeException if the filter is not valid\n     * @return bool true if validate\n     */\n    public static function validateFilterResources(array $values, string $filterName): bool\n    {\n        foreach ($values as $i => $resourceId) {\n            if (!is_int($i)) {\n                throw new CakeException(__('\"{0}\" is not a valid resource id for filter {1}.', $i, $filterName));\n            }\n            if (!is_scalar($resourceId) || empty($resourceId)) {\n                throw new CakeException(__('\"{0}\" is not a valid resource id for filter {1}.', $i));\n            }\n            if (!Validation::uuid($resourceId)) {\n                $msg = __('\"{0}\" is not a valid resource id for filter {1}.', $resourceId, $filterName);\n                throw new CakeException($msg);\n            }\n        }\n\n        return true;\n    }\n\n    /**\n     * Validate a filter that is a single group id\n     * Examples:\n     * - Bueno: '98c2bef5-cd5f-59e7-a1a7-0107c9a7cf08'\n     * - No Bueno: 'no-bueno'","sourceCodeStart":545,"sourceCodeEnd":581,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/src/Controller/Component/QueryStringComponent.php#L545-L581","documentation":"Thrown by QueryStringComponent::validateFilterResources when the key of an entry in a resource-id filter array is not an integer. Resource filters must be non-assoc, numerically indexed lists. The message interpolates the offending array key, so it may show a word instead of a value.","triggerScenarios":"Passing an associative array such as ['resource' => $id] to validateFilterResources, e.g. ?filter[has-id][resource]=<uuid> instead of ?filter[has-id][]=<uuid>.","commonSituations":"Client builds filters as key/value maps; query-string syntax uses a named key; refactored code passes an assoc options array directly.","solutions":["Use list syntax: filter[has-id][]=<uuid>.","Reindex with array_values($values) before validating.","Normalize or reject assoc filter maps at the client boundary."],"exampleFix":"// before\nGET /resources?filter[has-id][resource]=98c2bef5-cd5f-59e7-a1a7-0107c9a7cf08\n// after\nGET /resources?filter[has-id][]=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('Resource filter keys must be integers; use filter[has-id][]= syntax.');\n    }\n}","typeGuard":"function isIntKeyedList(mixed $values): bool {\n    return is_array($values) && $values === array_values($values);\n}","tryCatchPattern":"try {\n    $ok = QueryStringComponent::validateFilterResources($values, $filterName);\n} catch (\\Cake\\Core\\Exception\\CakeException $e) {\n    throw new BadRequestException($e->getMessage());\n}","preventionTips":["Use []= list syntax for resource id filters.","Normalize assoc maps with array_values() before sending.","Validate query-string builders with unit 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"}