{"record":{"id":"d4004569875e6444","repo":"passbolt/passbolt_api","slug":"the-resource-does-not-exist-resourcestagsaddcontroller","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/Tags/src/Controller/Tags/ResourcesTagsAddController.php","lineNumber":75,"sourceCode":"     * @throws \\Cake\\Http\\Exception\\BadRequestException\n     * @throws \\Cake\\Http\\Exception\\NotFoundException\n     * @return void\n     */\n    public function addPost(string $resourceId)\n    {\n        if (!Validation::uuid($resourceId)) {\n            throw new BadRequestException(__('The resource identifier should be a valid UUID.'));\n        }\n\n        $uac = $this->User->getAccessControl();\n        $data = $this->formatRequestData();\n        $data = $this->validateRequestData($data, $uac);\n\n        $options = ['contain' => ['all_tags' => 1, 'permission' => 1]];\n        /** @var \\App\\Model\\Entity\\Resource|null $resource */\n        $resource = $this->Resources->findView($uac->getId(), $resourceId, $options)->first();\n        if (is_null($resource)) {\n            throw new NotFoundException(__('The resource does not exist.'));\n        }\n\n        $tags = (new ResourcesTagsAddService())->add($uac, $resource, $data);\n        $tags = (new MetadataTagsRenderService())->renderTags($tags);\n        $this->success(__('The operation was successful.'), $tags);\n    }\n\n    /**\n     * Get and format the request data.\n     *\n     * @return array\n     */\n    private function formatRequestData(): array\n    {\n        $data = $this->getRequest()->getData();\n\n        // Data given in V1 format.\n        // @deprecated with v2","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/plugins/PassboltEe/Tags/src/Controller/Tags/ResourcesTagsAddController.php#L57-L93","documentation":"After UUID validation, addPost() loads the resource with Resources->findView($uac->getId(), $resourceId, options) filtered by the caller's permissions; if the query returns nothing it throws NotFoundException 'The resource does not exist.' The error covers both hard-nonexistence and soft cases where the resource exists but the user lacks permission (deleted, not shared).","triggerScenarios":"Adding tags to a resourceId that was deleted, that is not shared with the calling user, or that belongs to another user's private space.","commonSituations":"Stale resource id cached in a client after the resource was deleted; attempting tag updates on a resource visible to a teammate but not to you; soft-deleted resources still present in client state.","solutions":["Refresh the resource list (GET /resources.json) and confirm the id exists for this user","Log in as a user with access, or share the resource with the caller first","Check the resources table for the id and its deleted flag if debugging server-side"],"exampleFix":"// before\nawait addTags(resourceId, tags); // 404 if resource gone\n// after\nconst resource = await api.get(`/resources/${resourceId}.json`).catch(() => null);\nif (!resource) throw new Error('Resource unavailable for this user');\nawait addTags(resourceId, tags);","handlingStrategy":"try-catch","validationCode":"const res = await api.get(`/resources/${resourceId}.json`).catch(() => null);\nif (!res) throw new Error('Resource not accessible for this user');","typeGuard":"null","tryCatchPattern":"try { await addResourceTags(id, tags); } catch (e) { if (e.status === 404) { /* refresh resource list / check permissions */ } else throw e; }","preventionTips":["Refresh cached resource ids before mutations","Share resources with users who need tag access","Treat 404 as 'deleted or no permission' in clients"],"tags":["passbolt","resources","not-found","authorization"],"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-21T09:17:21.228Z"}