passbolt/passbolt_api · error · Cake\Web\Exception\ValidationException
Could not validate folders relations history data.
Error message
Could not validate folders relations history data.
What it means
Thrown by FoldersRelationsHistoryTable::create() when the FoldersRelation history entity returned by buildEntity() already contains validation errors before any save attempt. It means the input data (foreign model ids, user id, etc.) broke the table's validation rules.
Solutions
- Log/inspect the ValidationException errors payload to identify the offending field.
- Validate that all ids are valid UUIDs and reference existing entities before calling create().
- Fix the calling service so it never passes null parent/foreign ids when recording relation history.
- Catch ValidationException and handle gracefully in the move/rename workflow.
Example fix
// before
$foldersRelationsHistoryTable->create(['folder_parent_id' => $parentId ?? null]);
// after
if ($parentId !== null && !Uuid::isValid($parentId)) { throw new InvalidArgumentException('Invalid parent id'); }
$foldersRelationsHistoryTable->create(['folder_parent_id' => $parentId]); Defensive patterns
Strategy: validation
Validate before calling
foreach (['folder_parent_id','folder_foreign_id','user_id'] as $key) {
if (isset($data[$key]) && !Uuid::isValid($data[$key])) { throw new InvalidArgumentException("Invalid $key"); }
} Type guard
$validIds = fn(array $data): bool => collect($data)->every(fn($v, $k) => !str_contains($k, 'id') || $v === null || Uuid::isValid($v));
Try / catch
try { $table->create($data); } catch (ValidationException $e) { foreach ($e->getErrors() as $field => $errs) { /* log */ } } Prevention
- Never pass null parent/foreign ids when the relation expects one
- Validate ids against the DB before writing relation history
- Keep plugin migrations current so validation rules match schema
When it happens
Trigger: Calling create() with data failing validation rules — invalid or missing folder_parent_id/folder_foreign_id/user_id (non-UUID values), or an empty data array.
Common situations: Passing null or malformed identifiers when recording parent-child folder relation history; upgrading code between plugin versions where validation rules were tightened; association validation failures against Users or Folders tables.
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 data.
- Could not validate move data.
- Could not validate move data.
AI-assisted analysis of passbolt/passbolt_api@31c1bbc10f (2026-09-17).
Data as JSON: /api/errors/4ddd52881a9703e5.
Report an issue: GitHub.
Appendix: source
Thrown at plugins/PassboltCe/Folders/src/Model/Table/FoldersRelationsHistoryTable.php:167
],
]);
}
/**
* Create a new FoldersRelationHistory.
*
* @param array $data the data
* @return \Passbolt\Folders\Model\Entity\FoldersRelation
* @throws \App\Error\Exception\ValidationException
* @throws \Cake\Http\Exception\InternalErrorException
*/
public function create(array $data): FoldersRelation
{
// Check validation rules.
$folderRelationHistory = $this->buildEntity($data);
if ($folderRelationHistory->getErrors()) {
$msg = __('Could not validate folders relations history data.');
throw new ValidationException($msg, $folderRelationHistory, $this);
}
$folderRelationHistory = $this->save($folderRelationHistory);
// Check for errors while saving.
if (!$folderRelationHistory) {
throw new InternalErrorException('Could not save the folder relation history.');
}
// Check for validation errors. (associated models too).
if ($folderRelationHistory->getErrors()) {
$msg = __('Could not validate folders relations history data.');
throw new ValidationException($msg, $folderRelationHistory, $this);
}
return $folderRelationHistory;
}
}
View on GitHub (pinned to 31c1bbc10f)