passbolt/passbolt_api · error · CakeException

" " is not a valid value for filter .

Error message

"{0}" is not a valid value for filter {1}.

What it means

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.

Solutions

  1. Inspect the request query string and ensure the named filter is a non-empty string, e.g. ?filter[has-parent]=true
  2. Encode the value as a plain string client-side (cast or String($value)) before sending
  3. If the filter should accept lists or other types, change the filter declaration to the matching validator (validateFilterInList, etc.)
  4. Wrap the controller call in try/catch CakeException and return 400 with a clear message

Example fix

// before
axios.get('/users.json', { params: { 'filter[search]': '' } });
// after
const search = keywords.join(' ');
if (search) axios.get('/users.json', { params: { 'filter[search]': search } });
Defensive patterns

Strategy: validation

Validate before calling

if (!is_string($value) || $value === '') { throw new \InvalidArgumentException("Filter '$filtername' must be a non-empty string"); }

Type guard

$isValid = is_string($value) && $value !== '';

Try / catch

try { $qs->validateFilters($query); } catch (\Cake\Core\Exception\CakeException $e) { throw new BadRequestException($e->getMessage()); }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of passbolt/passbolt_api@31c1bbc10f (2026-09-17). Data as JSON: /api/errors/e5fb3e8b05ec046b. Report an issue: GitHub.

Appendix: source

Thrown at src/Controller/Component/QueryStringComponent.php:375

                }
            }
        }

        return true;
    }

    /**
     * Check if the filter is a valid string
     *
     * @param mixed $value to check
     * @param string $filtername for error message display
     * @throw CakeException if the filter is not valid
     * @return bool true if the filter is valid
     */
    public static function validateFilterString(mixed $value, string $filtername)
    {
        if (empty($value) || !is_string($value)) {
            throw new CakeException(__('"{0}" is not a valid value for filter {1}.', $value, $filtername));
        }

        return true;
    }

    /**
     * Check if the filter is a valid boolean
     *
     * @param mixed $values to check
     * @param string $filterName for error message display
     * @throw CakeException if the filter is not valid
     * @return bool true if the filter is valid
     */
    public static function validateFilterBoolean(mixed $values, string $filterName): bool
    {
        if (!is_bool($values)) {
            throw new CakeException(__('"{0}" is not a valid value for filter {1}.', $values, $filterName));
        }

View on GitHub (pinned to 31c1bbc10f)