passbolt/passbolt_api · error · Cake\Http\Exception\NotFoundException
The folder does not exist.
Error message
The folder does not exist.
What it means
Thrown by FoldersShareService::getFolder() when findById() scoped through FolderizableBehavior returns no row for the given folder id and user. Because the finder is user-scoped, this can mean either the folder does not exist or the user has no visibility of it.
Solutions
- Confirm the folder id via GET /folders (as the same user) before sharing.
- Ensure the user has at least read permission on the folder being shared.
- Check that the id belongs to the correct instance/environment (staging vs prod mixups).
- Catch NotFoundException and report 'folder not found or not visible' to the caller.
Example fix
// before
share($uac, 'folder-of-another-user', ...); // invisible to $uac
// after
$visible = $foldersTable->findById($id)->find(FolderizableBehavior::FINDER_NAME, user_id: $uac->getId())->first();
if (!$visible) { throw new BadRequestException('Folder not found or not visible'); } Defensive patterns
Strategy: validation
Validate before calling
$visible = $foldersTable->findById($folderId)
->find(FolderizableBehavior::FINDER_NAME, user_id: $uac->getId())->first();
if (!$visible) { throw new InvalidArgumentException('Folder not found or not visible to user'); } Type guard
$isShareable = fn(UserAccessControl $uac, string $id): bool => (bool) $foldersTable->findById($id)->find(FolderizableBehavior::FINDER_NAME, user_id: $uac->getId())->first();
Try / catch
try { $service->share($uac, $folderId, $changes); } catch (NotFoundException $e) { /* report folder not found/not visible */ } Prevention
- Confirm visibility of the folder as the sharing user before calling share
- Check permission rows when sharing fails for shared folders
- Avoid sharing ids pulled from other users' contexts or environments
When it happens
Trigger: Sharing a nonexistent folder id; sharing a folder the current user cannot see (no permission row, or personal folder of another user); id of a deleted folder.
Common situations: Share requests built from stale client state; users attempting to share folders that were shared with them but later revoked; automation passing ids of other users' personal folders.
Understand the failure class
Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.
Related errors
- The resource does not exist.
- Could not validate folder data.
- The folder does not exist.
- The folder does not exist.
- The folder does not exist.
AI-assisted analysis of passbolt/passbolt_api@31c1bbc10f (2026-09-17).
Data as JSON: /api/errors/5fd1a23de9403d61.
Report an issue: GitHub.
Appendix: source
Thrown at plugins/PassboltCe/Folders/src/Service/Folders/FoldersShareService.php:154
}
/**
* Retrieve the folder.
*
* @param string $folderId The folder identifier to retrieve.
* @param \App\Utility\UserAccessControl $uac UserAccessControl updating the resource
* @return \Passbolt\Folders\Model\Entity\Folder
* @throws \Cake\Http\Exception\NotFoundException If the folder does not exist.
*/
private function getFolder(string $folderId, UserAccessControl $uac): Folder
{
/** @var \Passbolt\Folders\Model\Entity\Folder|null $folder */
$folder = $this->foldersTable->findById($folderId)
->find(FolderizableBehavior::FINDER_NAME, user_id: $uac->getId())
->first();
if (empty($folder)) {
throw new NotFoundException(__('The folder does not exist.'));
}
return $folder;
}
/**
* Assert if the operator can share the given folder.
*
* @param \App\Utility\UserAccessControl $uac The operator
* @param \Passbolt\Folders\Model\Entity\Folder $folder The folder to assert
* @return void
* @throws \Cake\Http\Exception\ForbiddenException If the user cannot share the folder
*/
private function assertUserCanShare(UserAccessControl $uac, Folder $folder): void
{
$userId = $uac->getId();
$isAllowed = $this->userHasPermissionService
->check(PermissionsTable::FOLDER_ACO, $folder->id, $userId, Permission::OWNER);View on GitHub (pinned to 31c1bbc10f)