{"record":{"id":"9a3f1c78c1c4b731","repo":"passbolt/passbolt_api","slug":"the-resource-does-not-exist","errorCode":null,"errorMessage":"The resource does not exist.","messagePattern":"The resource does not exist\\.","errorType":"exception","errorClass":"Cake\\Http\\Exception\\NotFoundException","httpStatus":404,"severity":"error","filePath":"plugins/PassboltCe/Folders/src/Service/Resources/ResourcesAfterAccessGrantedService.php","lineNumber":105,"sourceCode":"\n    /**\n     * Retrieve the resource.\n     *\n     * @param \\App\\Utility\\UserAccessControl $uac UserAccessControl updating the resource\n     * @param string $resourceId The resource identifier to retrieve.\n     * @return \\App\\Model\\Entity\\Resource\n     * @throws \\Cake\\Http\\Exception\\NotFoundException If the resource does not exist.\n     */\n    private function getResource(UserAccessControl $uac, string $resourceId): Resource\n    {\n        try {\n            return $this->resourcesTable->get(\n                $resourceId,\n                finder: FolderizableBehavior::FINDER_NAME,\n                user_id: $uac->getId()\n            );\n        } catch (RecordNotFoundException $e) {\n            throw new NotFoundException(__('The resource does not exist.'));\n        }\n    }\n\n    /**\n     * Add a resource to a group of users trees.\n     *\n     * @param \\App\\Utility\\UserAccessControl $uac The operator\n     * @param \\App\\Model\\Entity\\Resource $resource The target resource\n     * @param string $groupId The target group\n     * @return void\n     * @throws \\Exception If something wrong occurred\n     */\n    private function addResourceToGroupUsersTrees(UserAccessControl $uac, Resource $resource, string $groupId): void\n    {\n        $groupUsersIds = $this->findGroupsUsersIdsNotHavingFolderRelation($resource, $groupId);\n        foreach ($groupUsersIds as $groupUserId) {\n            $this->addResourceToUserTree($uac, $resource, $groupUserId);\n        }","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/plugins/PassboltCe/Folders/src/Service/Resources/ResourcesAfterAccessGrantedService.php#L87-L123","documentation":"ResourcesAfterAccessGrantedService.getResource fetches the resource with the folderizable finder scoped to the given user; if the table throws RecordNotFoundException it is rethrown as a NotFoundException 'The resource does not exist.' This happens while adding the resource to the newly-granted users' folder trees after share/access grant. It signals the resource id referenced in the access-grant event no longer resolves for that user.","triggerScenarios":"Sharing a resource (granting group/user access) when the resource has been deleted concurrently, or the resource is soft-filtered out by FolderizableBehavior for that user, or the resource id in the event payload is invalid.","commonSituations":"Race condition: two users act on the same resource and one deletes it while the other shares it; stale share dialogs in the front-end referencing deleted resources; group edits re-triggering afterAccessGranted with outdated resource ids; folder personal-tree rebuild jobs processing removed resources.","solutions":["Confirm the resource still exists (GET /resources/<id>) before sharing; refresh the UI if it was deleted.","Check the resource is not filtered out for the target user (deleted flag / folder relations state).","Retry the share operation with the current resource list if a concurrent-delete race is suspected.","If reproducible without deletion, inspect FolderizableBehavior finder conditions and the user's permissions on the resource."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const res = await fetch(`/resources/${resourceId}.json`);\nif (!res.ok) throw new Error('Resource no longer exists; refresh before sharing');","typeGuard":null,"tryCatchPattern":"try { await shareResource(id, acl); } catch (e) { if (e.response?.status === 404) { refreshResourceList(); notifyUser('Resource was deleted'); } else throw e; }","preventionTips":["Refresh resource data before opening share dialogs.","Handle concurrent deletes by reloading lists after mutations.","Avoid caching resource ids across long-running sessions.","Treat 404 during share as a skip-and-continue in batch group operations."],"tags":["folders","resources","sharing","not-found"],"backgroundTag":"record-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"}