{"record":{"id":"e6af2519bc146cfd","repo":"passbolt/passbolt_api","slug":"0-is-not-a-valid-search-filter-it-should-be-between-1-and-64","errorCode":null,"errorMessage":"\"{0}\" is not a valid search filter. It should be between 1 and 64 char in length.","messagePattern":"\"(.+?)\" is not a valid search filter\\. It should be between 1 and 64 char in length\\.","errorType":"validation","errorClass":"CakeException","httpStatus":400,"severity":"error","filePath":"src/Controller/Component/QueryStringComponent.php","lineNumber":460,"sourceCode":"     * @return bool true if the filter is valid\n     */\n    public static function validateFilterSearch(array $values): bool\n    {\n        foreach ($values as $i => $keyword) {\n            if (!is_int($i)) {\n                throw new CakeException(__('\"{0}\" is not a valid search filter.', $i));\n            }\n            if (!is_scalar($keyword) || empty($keyword)) {\n                throw new CakeException(__('\"{0}\" is not a valid search filter.', $i));\n            }\n            if (!Validation::utf8($keyword)) {\n                $msg = __('\"{0}\" is not a valid search filter. It is not a UTF8 string.', $keyword);\n                throw new CakeException($msg);\n            }\n            if (!Validation::lengthBetween($keyword, 1, 64)) {\n                $msg = __('\"{0}\" is not a valid search filter.', $keyword) . ' ';\n                $msg .= __('It should be between 1 and 64 char in length.');\n                throw new CakeException($msg);\n            }\n        }\n\n        return true;\n    }\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     */","sourceCodeStart":442,"sourceCodeEnd":478,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/src/Controller/Component/QueryStringComponent.php#L442-L478","documentation":"Thrown by validateFilterSearch when a keyword passes scalar/UTF-8 checks but its length is outside 1–64 characters, enforced via Validation::lengthBetween. Search terms are capped to keep queries efficient and indexes usable.","triggerScenarios":"A search keyword longer than 64 chars (or somehow 0 after trimming upstream logic) is validated, e.g. filter[search][0]=<200-char string> from pasted paragraphs.","commonSituations":"Users pasting sentences/UUIDs-plus-text into search boxes; automated scripts sending whole documents as search terms; UI missing maxlength attribute.","solutions":["Truncate or split long inputs client-side to 64 chars per keyword before sending","Set maxlength=64 on the search input field","Server-side, if leniency is desired, pre-trim with mb_substr($keyword, 0, 64) before validating","Catch CakeException and return 400 explaining the 1–64 character limit"],"exampleFix":"// before\n<input type=\"text\" name=\"search\">\n// after\n<input type=\"text\" name=\"search\" maxlength=\"64\">","handlingStrategy":"validation","validationCode":"$clean = array_map(fn($k) => mb_substr((string)$k, 0, 64), $values);","typeGuard":"$isValid = fn($k): bool => is_scalar($k) && mb_strlen((string)$k) >= 1 && mb_strlen((string)$k) <= 64;","tryCatchPattern":"try { validateFilterSearch($values); } catch (\\Cake\\Core\\Exception\\CakeException $e) { throw new BadRequestException($e->getMessage()); }","preventionTips":["Set maxlength=64 on search inputs","Truncate pasted input client-side before sending","Split long text into multiple <=64-char keywords if multi-term search is intended"],"tags":["php","cakephp","validation","length-limit","search"],"backgroundTag":"value-out-of-range","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"}