{"record":{"id":"d8b75404737b8f71","repo":"passbolt/passbolt_api","slug":"0-is-not-a-valid-user-filter","errorCode":null,"errorMessage":"\"{0}\" is not a valid user filter.","messagePattern":"\"(.+?)\" is not a valid user filter\\.","errorType":"validation","errorClass":"CakeException","httpStatus":400,"severity":"error","filePath":"src/Controller/Component/QueryStringComponent.php","lineNumber":483,"sourceCode":"    }\n\n    /**\n     * Validate Users Filters\n     * Input must be a non-assoc array with utf8 char values between 3 and 64 char in length\n     * Examples:\n     * - 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     *","sourceCodeStart":465,"sourceCodeEnd":501,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/src/Controller/Component/QueryStringComponent.php#L465-L501","documentation":"Thrown by validateFilterUsers when an entry of a users filter array has a non-integer array key. Like the search filter, the users filter must be a numerically indexed list of user IDs; string keys indicate malformed structure.","triggerScenarios":"validateFilterUsers receives an array with associative keys, e.g. ['users' => 'uuid'] or filter[has-users][id]=..., instead of filter[has-users][0]=<uuid>.","commonSituations":"Clients nesting the user id under a named key; query parsers preserving string keys; hand-built arrays in tests or internal callers.","solutions":["Send user IDs numerically indexed: filter[has-users][0]=<uuid>&filter[has-users][1]=<uuid>","Server-side, reindex with array_values($values) before validating when the shape is trusted","Use a different filter/validator if a named parameter was intended","Catch CakeException and return 400 describing the expected list-of-uuids format"],"exampleFix":"// before\nparams['filter[has-users][id]'] = userId;\n// after\nparams['filter[has-users][0]'] = userId;","handlingStrategy":"validation","validationCode":"$isShaped = array_is_list($values); if (!$isShaped) { $values = array_values($values); }","typeGuard":"$isValid = is_array($values) && array_is_list($values);","tryCatchPattern":"try { validateFilterUsers($values, $filterName); } catch (\\Cake\\Core\\Exception\\CakeException $e) { throw new BadRequestException($e->getMessage()); }","preventionTips":["Send user filters as filter[has-users][0]=<uuid> numbered lists","Reindex trusted arrays with array_values() before validating","Cover the exact query-string key format in client integration tests"],"tags":["php","cakephp","query-string","validation","users"],"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"}