passbolt/passbolt_api · error · App\Error\Exception\ValidationException
Could not validate folder data.
Error message
Could not validate folder data.
What it means
A ValidationException raised by FoldersShareService::handleValidationErrors when the folder entity fails model validation after a permissions update during share. The service applies permission changes through the FoldersTable, and if getErrors() returns non-empty validation errors on the folder entity, it wraps them in this exception along with the entity and table for inspection.
Solutions
- Read the validation errors attached to the 400 response body (errors field) — they pinpoint the failing field on the folder/permission entities.
- Ensure each permission payload contains a valid type (1=READ, 7=UPDATE, 15=OWNER for folders) and a valid existing user/group id in aro.
- Remove duplicate permission entries for the same aro on the folder; a user should appear once per folder.
- Confirm the target users/groups still exist and are not deleted before sharing.
Example fix
// before
{"permissions":[{"aro":{"id":"not-a-uuid"},"type":99}]}
// after
{"permissions":[{"aro":{"id":"8e3874ae-4b40-590b-b236-2c2648d88a3b"},"type":7}]} Defensive patterns
Strategy: validation
Validate before calling
function validateSharePayload(permissions) {
const VALID = new Set([1, 7, 15]);
const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
return permissions.every(p =>
VALID.has(p.type) && UUID.test(p.aro?.id ?? '')
);
} Try / catch
try {
await foldersApi.share(folderId, permissions);
} catch (e) {
if (e.response?.status === 400 && e.response.data?.errors) {
console.error('Validation errors:', e.response.data.errors);
}
throw e;
} Prevention
- Validate permission types against the enum (1=READ, 7=UPDATE, 15=OWNER) before sending.
- Ensure aro ids are valid UUIDs of existing, non-deleted users/groups.
- Never send duplicate permissions for the same aro on one folder.
- Log and surface the per-field errors returned in the 400 body.
When it happens
Trigger: POST /folders/{id}/share with permission payloads that produce entity-level validation errors during the update (e.g. invalid permission type, invalid aro/aco identifiers, changes that break folder entity rules), or associated permission entities failing save validation.
Common situations: Automated API clients posting malformed permission payloads (wrong permission type constants, non-UUID aro foreign keys), duplicate permissions for the same user on the folder, or permission rows referencing deleted users/groups.
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 folder relation data.
- Could not validate folders relations history data.
- Could not validate move data.
AI-assisted analysis of passbolt/passbolt_api@31c1bbc10f (2026-09-17).
Data as JSON: /api/errors/27f660a84a6e4cdf.
Report an issue: GitHub.
Appendix: source
Thrown at plugins/PassboltCe/Folders/src/Service/Folders/FoldersShareService.php:214
$folder->setError('permissions', $e->getErrors());
$this->handleValidationErrors($folder);
}
return $entitiesChanges;
}
/**
* Handle folder validation errors.
*
* @param \Passbolt\Folders\Model\Entity\Folder $folder The target 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);
}
}
/**
* Move content of the folder which was self organized without sufficient permission (<UPDATE) to move it into
* a shared folder to the root of the operator.
*
* @param \App\Utility\UserAccessControl $uac The operator
* @param \Passbolt\Folders\Model\Entity\Folder $folder The target shared folder
* @return void
*/
private function moveSelfOrganizedContentWithInsufficientPermissionToRoot(
UserAccessControl $uac,
Folder $folder
): void {
/** @var array<\Passbolt\Folders\Model\Entity\FoldersRelation> $personalItems */
$personalItems = $this->foldersRelationsTable
->findByUserIdAndFolderParentId($uac->getId(), $folder->id)View on GitHub (pinned to 31c1bbc10f)