{"record":{"id":"8c043493daa0a16f","repo":"passbolt/passbolt_api","slug":"the-folder-does-not-exist-folderactionlogsfinder","errorCode":null,"errorMessage":"The folder does not exist.","messagePattern":"The folder does not exist\\.","errorType":"http","errorClass":"NotFoundException","httpStatus":404,"severity":"error","filePath":"plugins/PassboltEe/AuditLog/src/Utility/FolderActionLogsFinder.php","lineNumber":114,"sourceCode":"        ]);\n    }\n\n    /**\n     * @inheritDoc\n     */\n    public function find(UserAccessControl $uac, string $entityId, ?array $options = []): Query\n    {\n        if (!$this->isFeaturePluginEnabled(FoldersPlugin::class)) {\n            throw new FeaturePluginDisabledException();\n        }\n\n        // Check that the folder exists and is accessible.\n        /** @var \\Passbolt\\Folders\\Model\\Table\\FoldersTable $Folders */\n        $Folders = TableRegistry::getTableLocator()->get('Passbolt/Folders.Folders');\n        $folder = $Folders->findView($uac->getId(), $entityId, $options)->first();\n\n        if (empty($folder)) {\n            throw new NotFoundException('The folder does not exist.');\n        }\n\n        // Build query.\n        $q = $this->_getBaseQuery();\n\n        return $this->_filterQueryByFolderId($q, $entityId);\n    }\n}\n","sourceCodeStart":96,"sourceCodeEnd":123,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/plugins/PassboltEe/AuditLog/src/Utility/FolderActionLogsFinder.php#L96-L123","documentation":"This NotFoundException is thrown by the AuditLog FolderActionLogsFinder when the folder identified by $entityId cannot be loaded for the requesting user. The finder delegates to FoldersTable::findView(), which applies the user's access control (via UAC) to the folder visibility query; if no row is returned the folder either does not exist at all or the user lacks permission to see it, and rather than returning empty results the finder treats it as a not-found condition.","triggerScenarios":"Calling find() (directly or through the audit log endpoint) with a folder UUID that does not exist in the folders table, a soft-deleted folder, a malformed/non-UUID id, or a folder belonging to another user with whom the requesting user has no share/access. It also fires when querying with a UAC of a user whose role/permissions exclude the folder.","commonSituations":"Developers replaying audit log lookups after the folder was deleted, using IDs from a different environment (staging vs production), writing integration tests (e.g. testFolderActionLogsFinder_Find) without creating the folder fixture first, or querying as a non-admin user who is not a folder member.","solutions":["Verify the folder UUID exists: run a query on the folders table (SELECT id FROM folders WHERE id = '<uuid>') or call FoldersTable::findView with an admin UAC before invoking the finder.","If the folder exists but the user cannot see it, share the folder with that user or re-check the permissions/permissions table entries, or use a UAC with adequate access (e.g. admin).","Check the ID source: confirm you are not passing a resource/other entity id instead of a folder id, and that the id comes from the same environment/database.","In tests, ensure the folder is persisted via the Folders fixture/factory before calling the finder.","Handle the NotFoundException in the caller and return a 404 to the end user instead of a 500."],"exampleFix":"// before\n$logs = $finder->find($uac, $someResourceId); // wrong id type -> NotFoundException\n// after\n$folder = $Folders->findView($uac->getId(), $folderId)->first();\nif ($folder === null) {\n    throw new NotFoundException('The folder does not exist.'); // or handle gracefully\n}\n$logs = $folderActionLogsFinder->find($uac, $folderId);","handlingStrategy":"try-catch","validationCode":"$folderExists = TableRegistry::getTableLocator()->get('Passbolt/Folders.Folders')\n    ->findView($uac->getId(), $folderId)->first() !== null;\nif (!$folderExists) { /* abort or 404 before calling the finder */ }","typeGuard":"function folderIsAccessible($foldersTable, $uac, string $folderId): bool {\n    return is_string($folderId) && \\Cake\\Validation\\Validation::uuid($folderId)\n        && $foldersTable->findView($uac->getId(), $folderId)->first() !== null;\n}","tryCatchPattern":"use Passbolt\\AuditLog\\Utility\\FolderActionLogsFinder;\nuse Cake\\Http\\Exception\\NotFoundException;\ntry {\n    $logs = (new FolderActionLogsFinder())->find($uac, $folderId);\n} catch (NotFoundException $e) {\n    // respond 404: folder missing or not accessible for this user\n    $this->log('Folder not found or inaccessible: ' . $folderId, 'warning');\n}","preventionTips":["Always verify the folder id exists and is visible to the requesting UAC before querying audit logs.","Never reuse resource or user ids as folder ids; validate UUID format at the boundary.","Keep test fixtures creating the folder before any finder call.","Catch NotFoundException at the controller layer and return HTTP 404 rather than leaking a 500."],"tags":["not-found","folders","audit-log","permissions"],"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"}