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 FoldersDeleteService::getFolder() when foldersTable->get($folderId) raises RecordNotFoundException, converted to a NotFoundException. It means no folder exists with the given id, so nothing can be deleted.

Solutions

  1. Verify the folder id exists via GET /folders before deleting.
  2. Refresh the client's folder list to drop stale references.
  3. Check the id is a complete valid UUID (malformed ids can also fail lookup).
  4. Catch NotFoundException and treat it as an idempotent success in deletion scripts if the goal is 'folder gone'.

Example fix

// before
delete('c0ffee00-0000-0000-0000-000000000000') // never existed
// after
$folder = $foldersTable->findById($id)->first();
if ($folder) { delete($id); }
Defensive patterns

Strategy: try-catch

Validate before calling

if (!Uuid::isValid($id)) { throw new InvalidArgumentException('Invalid folder id'); }
if (!$foldersTable->exists(['id' => $id])) { return; /* nothing to delete */ }

Type guard

$folderExists = fn(string $id): bool => Uuid::isValid($id) && $foldersTable->exists(['id' => $id]);

Try / catch

try { $service->delete($uac, $id); } catch (NotFoundException $e) { /* treat as already deleted / idempotent */ }

Prevention

When it happens

Trigger: DELETE /folders/<id> with a nonexistent, already-deleted, or malformed-but-parseable id; deleting a folder that was concurrently removed by another user or a cascade delete.

Common situations: Client caching a stale folder id after the folder was deleted elsewhere; copy-paste of wrong UUID in scripts/API calls; soft-deleted data cleaned up by integrity tools.

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


AI-assisted analysis of passbolt/passbolt_api@31c1bbc10f (2026-09-17). Data as JSON: /api/errors/5d00e23abf0eba0d. Report an issue: GitHub.

Appendix: source

Thrown at plugins/PassboltCe/Folders/src/Service/Folders/FoldersDeleteService.php:124

                'folder' => $folder,
                'users' => $usersIds,
            ]);
        });
    }

    /**
     * Retrieve the folder.
     *
     * @param string $folderId The folder identifier to retrieve.
     * @return \Passbolt\Folders\Model\Entity\Folder
     * @throws \Cake\Http\Exception\NotFoundException If the folder does not exist.
     */
    private function getFolder(string $folderId): Folder
    {
        try {
            return $this->foldersTable->get($folderId);
        } catch (RecordNotFoundException $e) {
            throw new NotFoundException(__('The folder does not exist.'));
        }
    }

    /**
     * Assert that the current user can update the destination folder.
     *
     * @param \App\Utility\UserAccessControl $uac The current user
     * @param string $itemModel The target item model
     * @param string $itemId The target item
     * @return bool
     */
    private function checkUserCanDelete(UserAccessControl $uac, string $itemModel, string $itemId): bool
    {
        $userId = $uac->getId();

        return $this->userHasPermissionService->check($itemModel, $itemId, $userId, Permission::UPDATE);
    }

View on GitHub (pinned to 31c1bbc10f)