{"record":{"id":"5d00e23abf0eba0d","repo":"passbolt/passbolt_api","slug":"the-folder-does-not-exist-foldersdeleteservice","errorCode":null,"errorMessage":"The folder does not exist.","messagePattern":"The folder does not exist\\.","errorType":"http","errorClass":"Cake\\Http\\Exception\\NotFoundException","httpStatus":404,"severity":"error","filePath":"plugins/PassboltCe/Folders/src/Service/Folders/FoldersDeleteService.php","lineNumber":124,"sourceCode":"                'folder' => $folder,\n                'users' => $usersIds,\n            ]);\n        });\n    }\n\n    /**\n     * Retrieve the folder.\n     *\n     * @param string $folderId The folder identifier to retrieve.\n     * @return \\Passbolt\\Folders\\Model\\Entity\\Folder\n     * @throws \\Cake\\Http\\Exception\\NotFoundException If the folder does not exist.\n     */\n    private function getFolder(string $folderId): Folder\n    {\n        try {\n            return $this->foldersTable->get($folderId);\n        } catch (RecordNotFoundException $e) {\n            throw new NotFoundException(__('The folder does not exist.'));\n        }\n    }\n\n    /**\n     * Assert that the current user can update the destination folder.\n     *\n     * @param \\App\\Utility\\UserAccessControl $uac The current user\n     * @param string $itemModel The target item model\n     * @param string $itemId The target item\n     * @return bool\n     */\n    private function checkUserCanDelete(UserAccessControl $uac, string $itemModel, string $itemId): bool\n    {\n        $userId = $uac->getId();\n\n        return $this->userHasPermissionService->check($itemModel, $itemId, $userId, Permission::UPDATE);\n    }\n","sourceCodeStart":106,"sourceCodeEnd":142,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/plugins/PassboltCe/Folders/src/Service/Folders/FoldersDeleteService.php#L106-L142","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Verify the folder id exists via GET /folders before deleting.","Refresh the client's folder list to drop stale references.","Check the id is a complete valid UUID (malformed ids can also fail lookup).","Catch NotFoundException and treat it as an idempotent success in deletion scripts if the goal is 'folder gone'."],"exampleFix":"// before\ndelete('c0ffee00-0000-0000-0000-000000000000') // never existed\n// after\n$folder = $foldersTable->findById($id)->first();\nif ($folder) { delete($id); }","handlingStrategy":"try-catch","validationCode":"if (!Uuid::isValid($id)) { throw new InvalidArgumentException('Invalid folder id'); }\nif (!$foldersTable->exists(['id' => $id])) { return; /* nothing to delete */ }","typeGuard":"$folderExists = fn(string $id): bool => Uuid::isValid($id) && $foldersTable->exists(['id' => $id]);","tryCatchPattern":"try { $service->delete($uac, $id); } catch (NotFoundException $e) { /* treat as already deleted / idempotent */ }","preventionTips":["Refresh folder lists before delete operations","Validate UUID format client-side","Make delete pipelines idempotent for already-deleted folders"],"tags":["not-found","folders","api"],"backgroundTag":"entity-not-found","analyzedSha":"31c1bbc10f32808a607fa9bd81891e898779c0bc","analyzedAt":"2026-09-17T00:04:38.960Z","contentChangedAt":"2026-09-17T00:04:38.960Z","schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}