passbolt/passbolt_api · error · BadRequestException

The folder identifier should be a valid UUID.

Error message

The folder identifier should be a valid UUID.

What it means

Thrown by the AuditLog EE plugin's FolderLogsController when the folderId path parameter is not a valid UUID. The controller validates request sanity before looking up folder action logs, and any non-UUID identifier is rejected as a bad request before any permission or existence checks.

Solutions

  1. Pass the folder's passbolt UUID (36-char, 8-4-4-4-12 format) in the URL path
  2. Fetch the correct folder id via GET /folders.json and use its id field
  3. Fix URL construction in client code — ensure the id segment is interpolated and non-empty
  4. Validate the id client-side with a UUID regex or library before calling the endpoint

Example fix

// before
await fetch(`/folders/${folder.name}/logs.json`);
// after
await fetch(`/folders/${folder.id}/logs.json`); // folder.id is a UUID
Defensive patterns

Strategy: validation

Validate before calling

const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
if (!UUID_RE.test(folderId)) throw new Error('folderId must be a UUID');

Type guard

const isUuid = (v) => typeof v === 'string' && /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(v);

Try / catch

try {
  const logs = await getFolderLogs(folderId);
} catch (e) {
  if (e.code === 400 && /valid UUID/.test(e.message)) {
    console.error('Bad folder id:', folderId);
  } else { throw e; }
}

Prevention

When it happens

Trigger: GET /folders/<folderId>/logs.json where folderId is null, empty, an integer id, a slug, or otherwise not a UUID.

Common situations: Client code using a local numeric id or name instead of the passbolt UUID; missing route parameter due to a broken URL template; hand-crafted API calls in scripts/tests; copy-paste truncating the UUID.

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/50dd3705a36f8aa9. Report an issue: GitHub.

Appendix: source

Thrown at plugins/PassboltEe/AuditLog/src/Controller/FolderLogsController.php:46

     */
    public function getModelName(): string
    {
        return 'Folders';
    }

    /**
     * View action logs for a given folder.
     *
     * @param string|null $folderId folder id
     * @return void
     * @throws \Cake\Http\Exception\BadRequestException if the resource id has the wrong format
     * @throws \Cake\Http\Exception\NotFoundException if the user cannot access the given folder, or if the folder does not exist
     */
    public function view(?string $folderId = null)
    {
        // Check request sanity
        if (!Validation::uuid($folderId)) {
            throw new BadRequestException(__('The folder identifier should be a valid UUID.'));
        }

        $this->viewByEntity(new FolderActionLogsFinder(), $folderId);
    }
}

View on GitHub (pinned to 31c1bbc10f)