passbolt/passbolt_api · error · CakeException

" " is not a valid parent filter.

Error message

"{0}" is not a valid parent filter.

What it means

Thrown by QueryStringComponent::validateFilterParentFolders when the key of an entry in a parent-folder filter array is not an integer. Like the other list filters, parent filters must be numerically indexed non-assoc arrays. The message interpolates the offending key.

Solutions

  1. Use list syntax: filter[has-parent][]=<uuid> (or []=false for root).
  2. Reindex input with array_values($values) before validation.
  3. Reject or normalize assoc filter input at the client boundary.

Example fix

// before
GET /folders?filter[has-parent][folder]=98c2bef5-cd5f-59e7-a1a7-0107c9a7cf08
// after
GET /folders?filter[has-parent][]=98c2bef5-cd5f-59e7-a1a7-0107c9a7cf08
Defensive patterns

Strategy: validation

Validate before calling

if (!is_array($values)) { throw new \InvalidArgumentException('Filter must be an array.'); }
foreach (array_keys($values) as $k) {
    if (!is_int($k)) {
        throw new \InvalidArgumentException('Parent filter keys must be integers; use filter[has-parent][]= syntax.');
    }
}

Type guard

function isIntKeyedList(mixed $values): bool {
    return is_array($values) && $values === array_values($values);
}

Try / catch

try {
    $ok = QueryStringComponent::validateFilterParentFolders($values, $filterName);
} catch (\Cake\Core\Exception\CakeException $e) {
    throw new BadRequestException($e->getMessage());
}

Prevention

When it happens

Trigger: Passing an associative array such as ['folder' => $id] or ['this' => 'no'] to validateFilterParentFolders, e.g. via ?filter[has-parent][folder]=<uuid> instead of ?filter[has-parent][]=<uuid> (or =false).

Common situations: Client constructs the filter as a map instead of a list; URL query syntax mistake; reused assoc option arrays from other API calls.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


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

Appendix: source

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

        return true;
    }

    /**
     * Validate a filter that is an array of parent id
     * Examples:
     * - Bueno: [0 => '98c2bef5-cd5f-59e7-a1a7-0107c9a7cf08']
     * - No Bueno: ['this' => 'no']
     *
     * @param array $values array of group id to check
     * @param string|bool $filtername for error message display
     * @throw Exception if the filter is not valid
     * @return bool true if validate
     */
    public static function validateFilterParentFolders(array $values, string|bool $filtername)
    {
        foreach ($values as $i => $parentId) {
            if (!is_int($i)) {
                throw new CakeException(__('"{0}" is not a valid parent filter.', $i, $filtername));
            }
            if (!is_string($parentId) && $parentId !== false) {
                throw new CakeException(__('"{0}" is not a valid parent filter.', $i));
            }
            self::validateFilterParentFolder($parentId, $filtername);
        }

        return true;
    }

    /**
     * Validate a filter that is a single resource id
     * Examples:
     * - Bueno: '98c2bef5-cd5f-59e7-a1a7-0107c9a7cf08'
     * - No Bueno: 'no-bueno'
     *
     * @param array $values resources id
     * @param string $filterName name of filters

View on GitHub (pinned to 31c1bbc10f)