passbolt/passbolt_api · error · NotFoundException

The folder does not exist.

Error message

The folder does not exist.

What it means

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.

Solutions

  1. 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.
  2. 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).
  3. 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.
  4. In tests, ensure the folder is persisted via the Folders fixture/factory before calling the finder.
  5. Handle the NotFoundException in the caller and return a 404 to the end user instead of a 500.

Example fix

// before
$logs = $finder->find($uac, $someResourceId); // wrong id type -> NotFoundException
// after
$folder = $Folders->findView($uac->getId(), $folderId)->first();
if ($folder === null) {
    throw new NotFoundException('The folder does not exist.'); // or handle gracefully
}
$logs = $folderActionLogsFinder->find($uac, $folderId);
Defensive patterns

Strategy: try-catch

Validate before calling

$folderExists = TableRegistry::getTableLocator()->get('Passbolt/Folders.Folders')
    ->findView($uac->getId(), $folderId)->first() !== null;
if (!$folderExists) { /* abort or 404 before calling the finder */ }

Type guard

function folderIsAccessible($foldersTable, $uac, string $folderId): bool {
    return is_string($folderId) && \Cake\Validation\Validation::uuid($folderId)
        && $foldersTable->findView($uac->getId(), $folderId)->first() !== null;
}

Try / catch

use Passbolt\AuditLog\Utility\FolderActionLogsFinder;
use Cake\Http\Exception\NotFoundException;
try {
    $logs = (new FolderActionLogsFinder())->find($uac, $folderId);
} catch (NotFoundException $e) {
    // respond 404: folder missing or not accessible for this user
    $this->log('Folder not found or inaccessible: ' . $folderId, 'warning');
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

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/8c043493daa0a16f. Report an issue: GitHub.

Appendix: source

Thrown at plugins/PassboltEe/AuditLog/src/Utility/FolderActionLogsFinder.php:114

        ]);
    }

    /**
     * @inheritDoc
     */
    public function find(UserAccessControl $uac, string $entityId, ?array $options = []): Query
    {
        if (!$this->isFeaturePluginEnabled(FoldersPlugin::class)) {
            throw new FeaturePluginDisabledException();
        }

        // Check that the folder exists and is accessible.
        /** @var \Passbolt\Folders\Model\Table\FoldersTable $Folders */
        $Folders = TableRegistry::getTableLocator()->get('Passbolt/Folders.Folders');
        $folder = $Folders->findView($uac->getId(), $entityId, $options)->first();

        if (empty($folder)) {
            throw new NotFoundException('The folder does not exist.');
        }

        // Build query.
        $q = $this->_getBaseQuery();

        return $this->_filterQueryByFolderId($q, $entityId);
    }
}

View on GitHub (pinned to 31c1bbc10f)