passbolt/passbolt_api · error · App\Error\Exception\ValidationException
Could not validate folder data.
Error message
Could not validate folder data.
What it means
Thrown by FoldersCreateService::handleValidationErrors() when the Folder entity built for creation carries validation errors. It means the folder creation request data (name, parent id, etc.) failed the Folders table validation rules.
Solutions
- Read the errors array on the ValidationException and correct the offending field in the request payload.
- Ensure 'name' is a non-empty string within length limits and ids are valid UUIDs.
- Verify the parent folder exists and the user has update permission on it before creating a child.
- Catch ValidationException in the controller and return the error details to the client (the controller layer typically does this already).
Example fix
// before
POST /folders {"folder_parent_id":"not-a-uuid"}
// after
POST /folders {"name":"Projects","folder_parent_id":"e3f0a2b4-1c5d-4f8a-9b2e-7d6c1a0f5e33"} Defensive patterns
Strategy: validation
Validate before calling
$errors = [];
if (empty($data['name']) || strlen($data['name']) > 256) { $errors[] = 'name required (<=256 chars)'; }
if (isset($data['folder_parent_id']) && !Uuid::isValid($data['folder_parent_id'])) { $errors[] = 'invalid folder_parent_id'; }
if ($errors) { throw new InvalidArgumentException(implode('; ', $errors)); } Type guard
$isValidFolderPayload = fn(array $data): bool => isset($data['name']) && is_string($data['name']) && trim($data['name']) !== '' && (!isset($data['folder_parent_id']) || Uuid::isValid($data['folder_parent_id']));
Try / catch
try { $service->create($uac, $data); } catch (ValidationException $e) { return $this->respondValidationError($e->getErrors()); } Prevention
- Require a non-empty name in API clients
- Validate parent folder access (update permission) before creating children
- Use UUID validation on all ids client-side before submitting
When it happens
Trigger: POST /folders with a name that is empty/too long, an invalid folder_parent_id (non-UUID), or personal-space violations; calling createFolder/createFolderRelation with data that fails entity rules.
Common situations: API clients sending missing or blank 'name'; nesting a folder under a nonexistent or inaccessible parent; passing personal:true with a folder_parent_id the user cannot access.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- Could not validate folder data.
- Could not validate folder data.
- Could not validate folders relations history data.
- Could not validate group user data.
- Could not validate move data.
AI-assisted analysis of passbolt/passbolt_api@31c1bbc10f (2026-09-17).
Data as JSON: /api/errors/cc87113d0bbc0c88.
Report an issue: GitHub.
Appendix: source
Thrown at plugins/PassboltCe/Folders/src/Service/Folders/FoldersCreateService.php:163
'created_by' => true,
'modified_by' => true,
]);
return $this->foldersTable->newEntity($data, $options);
}
/**
* Handle folder validation errors.
*
* @param \Passbolt\Folders\Model\Entity\Folder $folder The folder
* @return void
* @throws \App\Error\Exception\ValidationException If the provided data does not validate.
*/
private function handleValidationErrors(Folder $folder): void
{
$errors = $folder->getErrors();
if (!empty($errors)) {
throw new ValidationException(__('Could not validate folder data.'), $folder, $this->foldersTable);
}
}
/**
* Create the user permission for the created folder.
*
* @param \App\Utility\UserAccessControl $uac The current user
* @param \Passbolt\Folders\Model\Entity\Folder $folder The folder
* @return void
*/
private function createPermission(UserAccessControl $uac, Folder $folder): void
{
$userId = $uac->getId();
$permissionData = [
'aco' => PermissionsTable::FOLDER_ACO,
'aco_foreign_key' => $folder->id,
'aro' => PermissionsTable::USER_ARO,
'aro_foreign_key' => $userId,View on GitHub (pinned to 31c1bbc10f)