{"record":{"id":"e5fb3e8b05ec046b","repo":"passbolt/passbolt_api","slug":"0-is-not-a-valid-value-for-filter-1","errorCode":null,"errorMessage":"\"{0}\" is not a valid value for filter {1}.","messagePattern":"\"(.+?)\" is not a valid value for filter (.+?)\\.","errorType":"validation","errorClass":"CakeException","httpStatus":400,"severity":"error","filePath":"src/Controller/Component/QueryStringComponent.php","lineNumber":375,"sourceCode":"                }\n            }\n        }\n\n        return true;\n    }\n\n    /**\n     * Check if the filter is a valid string\n     *\n     * @param mixed $value 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 validateFilterString(mixed $value, string $filtername)\n    {\n        if (empty($value) || !is_string($value)) {\n            throw new CakeException(__('\"{0}\" is not a valid value for filter {1}.', $value, $filtername));\n        }\n\n        return true;\n    }\n\n    /**\n     * Check if the filter is a valid boolean\n     *\n     * @param mixed $values 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 validateFilterBoolean(mixed $values, string $filterName): bool\n    {\n        if (!is_bool($values)) {\n            throw new CakeException(__('\"{0}\" is not a valid value for filter {1}.', $values, $filterName));\n        }","sourceCodeStart":357,"sourceCodeEnd":393,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/src/Controller/Component/QueryStringComponent.php#L357-L393","documentation":"Thrown by QueryStringComponent::validateFilterString when a query-string filter expected to be a string is empty or not a string. The component validates every declared filter before the controller touches it, so malformed client input is rejected early with this CakeException. The message includes the offending value and the filter name.","triggerScenarios":"Calling validateFilterString($value, $filtername) (directly or via validateFilters) with an empty value, null, an array, an int, or any non-string for a filter declared as string type, e.g. ?filter[search]=[] or a filter that maps to a string validator receiving nothing.","commonSituations":"Frontend sends a filter parameter with no value or sends a JSON array/object where a string is expected; API version changes where a previously optional filter became typed; encoding issues producing empty values after URL decoding.","solutions":["Inspect the request query string and ensure the named filter is a non-empty string, e.g. ?filter[has-parent]=true","Encode the value as a plain string client-side (cast or String($value)) before sending","If the filter should accept lists or other types, change the filter declaration to the matching validator (validateFilterInList, etc.)","Wrap the controller call in try/catch CakeException and return 400 with a clear message"],"exampleFix":"// before\naxios.get('/users.json', { params: { 'filter[search]': '' } });\n// after\nconst search = keywords.join(' ');\nif (search) axios.get('/users.json', { params: { 'filter[search]': search } });","handlingStrategy":"validation","validationCode":"if (!is_string($value) || $value === '') { throw new \\InvalidArgumentException(\"Filter '$filtername' must be a non-empty string\"); }","typeGuard":"$isValid = is_string($value) && $value !== '';","tryCatchPattern":"try { $qs->validateFilters($query); } catch (\\Cake\\Core\\Exception\\CakeException $e) { throw new BadRequestException($e->getMessage()); }","preventionTips":["Always pass raw query values through a string cast/coercion layer before filter validation","Log the full query string on validation failure to spot client encoding bugs","Document each filter's expected type in the endpoint docs"],"tags":["php","cakephp","query-string","validation"],"backgroundTag":"invalid-argument-value","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"}