{"record":{"id":"60bfcdbccc3b9355","repo":"passbolt/passbolt_api","slug":"the-resource-does-not-exist-resourceactionlogsfinder","errorCode":null,"errorMessage":"The resource does not exist.","messagePattern":"The resource does not exist\\.","errorType":"http","errorClass":"NotFoundException","httpStatus":404,"severity":"error","filePath":"plugins/PassboltEe/AuditLog/src/Utility/ResourceActionLogsFinder.php","lineNumber":177,"sourceCode":"            ],\n        ]);\n    }\n\n    /**\n     * Check if a given user has access to a resource.\n     *\n     * @param \\App\\Utility\\UserAccessControl $uac user\n     * @param string $resourceId resource id\n     * @return Resource whether or not he has access to the resource\n     */\n    protected function _checkUserCanAccessResource(UserAccessControl $uac, string $resourceId): Resource\n    {\n        /** @var \\App\\Model\\Table\\ResourcesTable $Resource */\n        $Resource = TableRegistry::getTableLocator()->get('Resources');\n        /** @var Resource|null $resource */\n        $resource = $Resource->findView($uac->getId(), $resourceId)->first();\n        if (empty($resource)) {\n            throw new NotFoundException(__('The resource does not exist.'));\n        }\n\n        return $resource;\n    }\n\n    /**\n     * @inheritDoc\n     */\n    public function find(UserAccessControl $uac, string $entityId, ?array $options = []): Query\n    {\n        // Check that user can access to resource.\n        $this->_checkUserCanAccessResource($uac, $entityId);\n\n        // Build query.\n        $q = $this->_getBaseQuery();\n\n        return $this->_filterQueryByResourceId($q, $entityId);\n    }","sourceCodeStart":159,"sourceCodeEnd":195,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/plugins/PassboltEe/AuditLog/src/Utility/ResourceActionLogsFinder.php#L159-L195","documentation":"This NotFoundException is raised by ResourceActionLogsFinder::_checkUserCanAccessResource when ResourcesTable::findView($uac, $resourceId) returns no row. findView filters resources by the requesting user's access rules, so an empty result means the resource is missing, soft-deleted, or invisible to that user; the finder refuses to return action logs for a resource the user cannot access.","triggerScenarios":"Calling ResourceActionLogsFinder::find() with a resource UUID that does not exist, an id from another environment, a deleted resource, or a resource the UAC user has no permission on (not shared with them, or non-admin user without access).","commonSituations":"Audit log endpoints called after a resource was deleted; lookups with a folder id mistakenly passed as a resource id; staging/production id mix-ups; tests that forget to persist the resource; querying as a user who is not a member of the resource's shared groups.","solutions":["Confirm the resource exists with an admin UAC or direct SQL (SELECT id, deleted FROM resources WHERE id = '<uuid>') before calling the finder.","If the resource exists but the user lacks access, share the resource with the user/adjust permissions entries, or query with sufficient privileges.","Validate that the id passed is actually a resource id (not a folder or user id) and is a valid UUID from the same environment.","In tests, persist the resource (and its owner/permissions) before invoking find().","Catch the NotFoundException in the controller/endpoint layer and map it to an HTTP 404 response."],"exampleFix":"// before\n$logs = $resourceActionLogsFinder->find($limitedUserUac, $resourceId); // user has no access -> NotFoundException\n// after\n$resource = $Resources->findView($uac->getId(), $resourceId)->first();\nif ($resource === null) {\n    // resolve access: share resource or use an authorized UAC\n    throw new NotFoundException(__('The resource does not exist.'));\n}\n$logs = $resourceActionLogsFinder->find($uac, $resourceId);","handlingStrategy":"validation","validationCode":"$resource = TableRegistry::getTableLocator()->get('Resources')\n    ->findView($uac->getId(), $resourceId)->first();\nif ($resource === null) {\n    throw new Cake\\Http\\Exception\\NotFoundException(__('The resource does not exist.'));\n}","typeGuard":"function resourceIsVisible($resourcesTable, $uac, $resourceId): bool {\n    return is_string($resourceId) && \\Cake\\Validation\\Validation::uuid($resourceId)\n        && $resourcesTable->findView($uac->getId(), $resourceId)->first() !== null;\n}","tryCatchPattern":null,"preventionTips":["Pre-check resource visibility with ResourcesTable::findView for the exact UAC that will call the finder.","Ensure permissions/sharing exist for non-admin users before running audit log lookups.","Distinguish folder ids from resource ids; both are UUIDs and easy to mix up.","In tests, persist the resource and its owner permissions before invoking the finder."],"tags":["not-found","resources","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"}