passbolt/passbolt_api · error · NotFoundException

The metadata key does not exist or has been deleted.

Error message

The metadata key does not exist or has been deleted.

What it means

Existence check in MetadataKeyUpdateService::update(): after validating the id format, the service looks up the metadata key by id and, when no non-deleted key row matches, fails the admin's key-update operation with a not-found-style error. Fires when the key id refers to a key that was never created, or that has been soft-deleted; clients must refresh their key list and use an existing key id.

Solutions

  1. Re-fetch GET /metadata/keys and confirm the id exists
  2. Point the client at the correct environment/instance
  3. Handle 404 by refreshing local key cache instead of retrying
Defensive patterns

Strategy: validation

Validate before calling

const key = (await listMetadataKeys()).find(k => k.id === id);
if (!key) throw new Error(`metadata key ${id} not found`);

Try / catch

try {
  await updateMetadataKey(id, dto);
} catch (e) {
  if (e.status === 404) await refreshKeyCache();
  throw e;
}

Prevention

When it happens

Trigger: PUT /metadata/keys/<valid-uuid> where the id is unknown, from another environment, or already deleted.

Common situations: Stale cached key list; wrong environment (staging id used against prod); key deleted by another admin in the meantime; DB reset without refreshing client data.

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

Appendix: source

Thrown at plugins/PassboltCe/Metadata/src/Service/MetadataKey/MetadataKeyUpdateService.php:62

     * @throws \Cake\Http\Exception\NotFoundException if the key does not exist or is already expired
     * @throws \Cake\Http\Exception\BadRequestException if the key id format is Invalid or some items are still using the key
     */
    public function update(UserAccessControl $uac, string $id, MetadataKeyUpdateDto $dto): void
    {
        $uac->assertIsAdmin();

        if (!Validation::uuid($id)) {
            throw new BadRequestException(__('The metadata key ID should be a valid UUID.'));
        }

        $metadataKeysTable = $this->fetchTable('Passbolt/Metadata.MetadataKeys');

        // Assert the key exist
        try {
            /** @var \Passbolt\Metadata\Model\Entity\MetadataKey $metadataKey */
            $metadataKey = $metadataKeysTable->get($id);
        } catch (RecordNotFoundException $exception) { // @phpstan-ignore-line
            throw new NotFoundException(__('The metadata key does not exist or has been deleted.'), 404, $exception);
        }

        // Assert fingerprint is the same
        if ($metadataKey->fingerprint !== $dto->fingerprint) {
            throw new NotFoundException(__('The metadata key fingerprint is invalid.'));
        }

        // Assert the key is not already deleted
        if ($metadataKey->isDeleted()) {
            throw new NotFoundException(__('The metadata key has already been deleted.'));
        }

        // Assert they key was not previously marked as expired
        if ($metadataKey->isExpired()) {
            throw new BadRequestException(__('The metadata key is already marked as expired.'));
        }

        // Patch the key deleted field with the current time

View on GitHub (pinned to 31c1bbc10f)