passbolt/passbolt_api · error · NotFoundException

The resource does not exist.

Error message

The resource does not exist.

What it means

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).

Solutions

  1. Refresh the resource list (GET /resources.json) and confirm the id exists for this user
  2. Log in as a user with access, or share the resource with the caller first
  3. Check the resources table for the id and its deleted flag if debugging server-side

Example fix

// before
await addTags(resourceId, tags); // 404 if resource gone
// after
const resource = await api.get(`/resources/${resourceId}.json`).catch(() => null);
if (!resource) throw new Error('Resource unavailable for this user');
await addTags(resourceId, tags);
Defensive patterns

Strategy: try-catch

Validate before calling

const res = await api.get(`/resources/${resourceId}.json`).catch(() => null);
if (!res) throw new Error('Resource not accessible for this user');

Type guard

null

Try / catch

try { await addResourceTags(id, tags); } catch (e) { if (e.status === 404) { /* refresh resource list / check permissions */ } else throw e; }

Prevention

When it happens

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

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

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

Appendix: source

Thrown at plugins/PassboltEe/Tags/src/Controller/Tags/ResourcesTagsAddController.php:75

     * @throws \Cake\Http\Exception\BadRequestException
     * @throws \Cake\Http\Exception\NotFoundException
     * @return void
     */
    public function addPost(string $resourceId)
    {
        if (!Validation::uuid($resourceId)) {
            throw new BadRequestException(__('The resource identifier should be a valid UUID.'));
        }

        $uac = $this->User->getAccessControl();
        $data = $this->formatRequestData();
        $data = $this->validateRequestData($data, $uac);

        $options = ['contain' => ['all_tags' => 1, 'permission' => 1]];
        /** @var \App\Model\Entity\Resource|null $resource */
        $resource = $this->Resources->findView($uac->getId(), $resourceId, $options)->first();
        if (is_null($resource)) {
            throw new NotFoundException(__('The resource does not exist.'));
        }

        $tags = (new ResourcesTagsAddService())->add($uac, $resource, $data);
        $tags = (new MetadataTagsRenderService())->renderTags($tags);
        $this->success(__('The operation was successful.'), $tags);
    }

    /**
     * Get and format the request data.
     *
     * @return array
     */
    private function formatRequestData(): array
    {
        $data = $this->getRequest()->getData();

        // Data given in V1 format.
        // @deprecated with v2

View on GitHub (pinned to 31c1bbc10f)