passbolt/passbolt_api · error · NotFoundException
The metadata private key does not exist or has been deleted.
Error message
The metadata private key does not exist or has been deleted.
What it means
NotFoundException thrown when no metadata private key row matches both the given ID and the current user (user_id = uac id). firstOrFail() raises RecordNotFoundException which the service converts to a 404. Note the query scopes by user, so a key that exists but belongs to another user also yields 404.
Solutions
- Confirm the key ID exists via GET on the metadata private keys collection first.
- Ensure the authenticated user is the owner of the key; only owners can update their private keys.
- Refresh the local cache of metadata private keys if records were deleted elsewhere.
Defensive patterns
Strategy: try-catch
Validate before calling
const key = await api.get(`/metadata/private-keys/${id}`); // 404 here means no retry needed
if (key.userId !== currentUserId) throw new Error('not the owner'); Try / catch
catch (NotFoundException) { // 404
// refresh local cache; do not retry with the same ID
await refreshMetadataPrivateKeys();
} Prevention
- Fetch the key before updating to confirm existence and ownership
- Only update keys owned by the authenticated user
- Invalidate caches when keys are deleted or rotated
When it happens
Trigger: PUT to a metadata private key ID that does not exist, was deleted, or belongs to a different user than the authenticated one.
Common situations: Stale client cache referencing a deleted key; using another user's key ID; a typo'd UUID; the key was removed during metadata key rotation.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Missing metadata private key.
- Record not found
- The authentication token could not be found.
- The metadata key has already been deleted.
- The metadata private key could not be updated. Please try…
AI-assisted analysis of passbolt/passbolt_api@31c1bbc10f (2026-09-17).
Data as JSON: /api/errors/55fd2dfe9ae754b5.
Report an issue: GitHub.
Appendix: source
Thrown at plugins/PassboltCe/Metadata/src/Service/MetadataPrivateKeysUpdateService.php:65
public function update(UserAccessControl $uac, string $privateKeyId, array $data): MetadataPrivateKey
{
if (!isset($data['data']) || !is_string($data['data'])) {
throw new BadRequestException(__('The request data is invalid.'));
}
if (!Validation::uuid($privateKeyId)) {
throw new BadRequestException(__('The request data is invalid.'));
}
/** @var \Passbolt\Metadata\Model\Table\MetadataPrivateKeysTable $metadataPrivateKeysTable */
$metadataPrivateKeysTable = $this->fetchTable('Passbolt/Metadata.MetadataPrivateKeys');
try {
/** @var \Passbolt\Metadata\Model\Entity\MetadataPrivateKey $metadataPrivateKey */
$metadataPrivateKey = $metadataPrivateKeysTable
->find()
->where(['user_id' => $uac->getId(), 'id ' => $privateKeyId])
->firstOrFail();
} catch (RecordNotFoundException $exception) {
throw new NotFoundException(__('The metadata private key does not exist or has been deleted.'));
}
if ($metadataPrivateKey->modified_by === $uac->getId()) {
throw new BadRequestException(__('The metadata private key was already edited by the user.'));
}
$metadataPrivateKeysTable->patchEntity($metadataPrivateKey, [
'data' => $data['data'],
'modified_by' => $uac->getId(),
], [
'accessibleFields' => [
'data' => true,
'modified_by' => true,
],
]);
if (!empty($metadataPrivateKey->getErrors())) {
$this->handleValidationErrors($metadataPrivateKey, $metadataPrivateKeysTable);
}View on GitHub (pinned to 31c1bbc10f)