passbolt/passbolt_api · critical · Cake\Http\Exception\InternalErrorException
Could not create the resource folder relation, please try…
Error message
Could not create the resource folder relation, please try again later.
What it means
After a resource is created, ResourcesAfterCreateService tries to insert the resource's folder relation (its personal-tree entry). If FoldersRelationsCreateService->create() throws any Exception, it is wrapped in InternalErrorException 'Could not create the resource folder relation, please try again later.' This is an internal persistence failure, not a client data problem.
Solutions
- Retry the resource creation as the message suggests — transient DB issues often resolve on retry.
- Check the previous exception (chained in the logs) for the root cause: FK violation, connection error, duplicate key, etc.
- Verify folder_parent_id, if provided, references an existing folder the creating user can access.
- Run folder tree repair (e.g. the folders repair/consistency commands) if personal trees are corrupted.
- Check database health and migration status (ddev refresh / migrations) if it reproduces.
Example fix
// before: creating with a parent the user has no relation to
await createResource({ name: 'pw', folder_parent_id: otherUsersFolderId });
// after: use a folder the creator can access, or omit parent
await createResource({ name: 'pw', folder_parent_id: myOwnFolderId }); Defensive patterns
Strategy: retry
Validate before calling
if (folderParentId && !userFolders.some(f => f.id === folderParentId)) throw new Error('Parent folder not accessible'); Try / catch
try { await createResource(data); } catch (e) { if (/folder relation/.test(e.message)) { await sleep(backoff); return createResource(data); } throw e; } Prevention
- Retry transient failures with backoff before surfacing to the user.
- Only pass folder_parent_id values the creating user has a relation to.
- Run folder-tree consistency/repair commands after failed migrations.
- Monitor database health and lock timeouts on the server.
When it happens
Trigger: Creating a resource when the folders_relations insert fails — e.g. invalid/missing folder_parent_id FK, database connection failure, constraint violation, or the parent folder relation row missing for the creating user.
Common situations: Database outages or lock timeouts during resource creation; corrupted personal folder trees after failed migrations; passing a folder_parent_id of a folder the user has no relation to; concurrency conflicts on folders_relations rows.
Related errors
- 500
- Could not create the folder, please try again later.
- Could not delete the draft SSO settings.
- Could not delete the group
- Could not delete the role, please try again later.
AI-assisted analysis of passbolt/passbolt_api@31c1bbc10f (2026-09-17).
Data as JSON: /api/errors/3b9927b4cac7c26b.
Report an issue: GitHub.
Appendix: source
Thrown at plugins/PassboltCe/Folders/src/Service/Resources/ResourcesAfterCreateService.php:91
if (!is_null($folderParentId)) {
$this->validateParentFolder($uac, $resource, $folderParentId);
if ($resource->hasErrors()) {
return;
}
}
$folderRelationData = [
'foreign_model' => FoldersRelation::FOREIGN_MODEL_RESOURCE,
'foreign_id' => $resource->id,
'folder_parent_id' => $folderParentId,
'user_id' => $uac->getId(),
];
try {
$this->foldersRelationsCreateService->create($folderRelationData);
$resource->set('folder_parent_id', $folderParentId);
} catch (Exception $e) {
throw new InternalErrorException(
'Could not create the resource folder relation, please try again later.',
500,
$e
);
}
}
/**
* Validate the parent folder
*
* @param \App\Utility\UserAccessControl $uac The current user
* @param \App\Model\Entity\Resource $resource The created resource.
* @param string|null $folderParentId The parent folder to validate
* @return void
* @throws \App\Error\Exception\CustomValidationException If the parent folder does not exist.
* @throws \Cake\Http\Exception\ForbiddenException If the user is not allowed to insert content in the parent folder.
*/
private function validateParentFolder(View on GitHub (pinned to 31c1bbc10f)