passbolt/passbolt_api · error · BadRequestException
The resource identifier should be a valid UUID.
Error message
The resource identifier should be a valid UUID.
What it means
Thrown by the AuditLog EE plugin's ResourceLogsController when the resourceId path parameter is not a valid UUID. It is the request sanity check for the resource activity logs endpoint and fires before any permission or existence verification.
Solutions
- Provide the resource's passbolt UUID in the URL path
- Look up the correct id via GET /resources.json and use the id property
- Add client-side UUID validation before invoking the logs endpoint
- Fix route/template code that drops or mangles the id segment
Example fix
// before
const url = `/resources/${idx}/logs.json`; // idx is array index
// after
const url = `/resources/${resource.id}/logs.json`; 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(resourceId)) throw new Error('resourceId 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 getResourceLogs(resourceId);
} catch (e) {
if (e.code === 400 && /valid UUID/.test(e.message)) {
refreshResourceList();
} else { throw e; }
} Prevention
- Use resource.id from API responses, never array indices or slugs
- Validate id format before the request
- Ensure URL builders interpolate the id correctly
- Add tests that call the logs endpoint with real fetched ids
When it happens
Trigger: GET /resources/<resourceId>/logs.json where resourceId is missing, null, numeric, or otherwise not a UUID.
Common situations: Scripts or integrations using legacy numeric ids; URL built without interpolating the resource id; test fixtures with fake ids like 'xxx'; truncated UUIDs from copy-paste.
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
- The folder identifier should be a valid UUID.
- The user identifier should be a valid UUID.
- The comment id is not valid.
- The group id is not valid.
- The group identifier should be a valid UUID.
AI-assisted analysis of passbolt/passbolt_api@31c1bbc10f (2026-09-17).
Data as JSON: /api/errors/237b41bb21adc84c.
Report an issue: GitHub.
Appendix: source
Thrown at plugins/PassboltEe/AuditLog/src/Controller/ResourceLogsController.php:46
*/
public function getModelName(): string
{
return 'Resources';
}
/**
* View action logs for a given resource.
*
* @param string|null $resourceId resource 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 resource, or if the resource does not exist
*/
public function view(?string $resourceId = null)
{
// Check request sanity
if (!Validation::uuid($resourceId)) {
throw new BadRequestException(__('The resource identifier should be a valid UUID.'));
}
$this->viewByEntity(new ResourceActionLogsFinder(), $resourceId);
}
}
View on GitHub (pinned to 31c1bbc10f)