{"record":{"id":"787a4fa930f04e49","repo":"passbolt/passbolt_api","slug":"0-is-not-a-valid-user-id-for-filter-1","errorCode":null,"errorMessage":"\"{0}\" is not a valid user id for filter {1}.","messagePattern":"\"(.+?)\" is not a valid user id for filter (.+?)\\.","errorType":"validation","errorClass":"CakeException","httpStatus":400,"severity":"error","filePath":"src/Controller/Component/QueryStringComponent.php","lineNumber":489,"sourceCode":"     * - Bueno: [0 => '98c2bef5-cd5f-59e7-a1a7-0107c9a7cf08']\n     * - No Bueno: ['this' => 'no']\n     *\n     * @param array $values array of user id to check\n     * @param string $filterName for error message display\n     * @throw CakeException if the filter is not valid\n     * @return bool true if the filter is valid\n     */\n    public static function validateFilterUsers(array $values, string $filterName): bool\n    {\n        foreach ($values as $i => $userId) {\n            if (!is_int($i)) {\n                throw new CakeException(__('\"{0}\" is not a valid user filter.', $i, $filterName));\n            }\n            if (!is_scalar($userId) || empty($userId)) {\n                throw new CakeException(__('\"{0}\" is not a valid user filter.', $i));\n            }\n            if (!Validation::uuid($userId)) {\n                throw new CakeException(__('\"{0}\" is not a valid user id for filter {1}.', $userId, $filterName));\n            }\n        }\n\n        return true;\n    }\n\n    /**\n     * Validate a filter that is an array of group 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 $filterName for error message display\n     * @throw CakeException if the filter is not valid\n     * @return bool true if validate\n     */\n    public static function validateFilterGroups(array $values, string $filterName): bool","sourceCodeStart":471,"sourceCodeEnd":507,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/src/Controller/Component/QueryStringComponent.php#L471-L507","documentation":"Thrown by QueryStringComponent::validateFilterUsers when a value in a user-id filter array (e.g. the 'has-users' filter) passes the scalar/empty checks but fails Cake\\Validation::uuid(), meaning it is not a well-formed UUID. The API expects every user id in list-type query filters to be a UUID string. It is raised as a CakeException during query-string validation before any controller action logic runs.","triggerScenarios":"Calling an endpoint that supports a user filter (e.g. GET /resources?filter[has-users][]=<value>) with a value that is a non-empty scalar but not a UUID, such as 'abc', an email address, or a truncated id. Keys must be integers (non-assoc array); keys are checked before this UUID check, so this specific error fires only for a bad string value under a valid integer key.","commonSituations":"Client code passes a user's email or label instead of the id; a stored id was truncated or reformatted by middleware/DB; an older API version accepted non-UUID identifiers and scripts still send them; copy-paste errors when hardcoding ids in integration tests.","solutions":["Inspect the failing value shown in the exception message and replace it with the user's actual UUID (look it up via GET /users).","Validate each filter value with \\Cake\\Validation\\Validation::uuid() client-side before sending the request.","Ensure the filter array is numerically indexed (filter[has-users][]=... produces integer keys; avoid custom keys).","If ids come from another system, confirm they were not re-encoded (e.g. base64 or with dashes stripped) between storage and the request."],"exampleFix":"// before\n$filter = ['has-users' => ['ada@example.com']];\n// after\n$filter = ['has-users' => ['98c2bef5-cd5f-59e7-a1a7-0107c9a7cf08']];","handlingStrategy":"validation","validationCode":"use Cake\\Validation\\Validation;\nif (!is_array($values) || array_values($values) !== $values) {\n    throw new \\InvalidArgumentException('Filter must be a list.');\n}\nforeach ($values as $v) {\n    if (!is_string($v) || !Validation::uuid($v)) {\n        throw new \\InvalidArgumentException(\"Not a valid user UUID: \" . var_export($v, true));\n    }\n}","typeGuard":"function isUserFilterList(mixed $values): bool {\n    return is_array($values)\n        && array_values($values) === $values\n        && array_all($values, fn($v) => is_string($v) && \\Cake\\Validation\\Validation::uuid($v));\n}","tryCatchPattern":"try {\n    $result = $resourcesIndex->withFilter('has-users', $userIds);\n} catch (\\Cake\\Core\\Exception\\CakeException $e) {\n    if (str_contains($e->getMessage(), 'is not a valid user id')) {\n        $logger->warning('Bad user filter id', ['msg' => $e->getMessage()]);\n        return $this->response->withStatus(400);\n    }\n    throw $e;\n}","preventionTips":["Always fetch and use real UUIDs from the users index endpoint, never emails or names.","Run Validation::uuid() on filter values before building the request.","Keep filter arrays numerically indexed; use []= query syntax."],"tags":["validation","uuid","query-string","filter"],"backgroundTag":"invalid-identifier-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"}