passbolt/passbolt_api · error · ValidationException
The OpenPGP key data is not valid.
Error message
The OpenPGP key data is not valid.
What it means
After building the user's MetadataPrivateKey entity, the service throws ValidationException with 'The OpenPGP key data is not valid.' if the entity has validation errors or fails table rules check. The encrypted metadata private key data produced for the user did not pass entity/application validation.
Solutions
- Enable debug mode and read the logged json_encode'd entity errors for the exact failing field
- Re-validate the user's public key and re-run the share
- Verify the generated encrypted message is a non-empty valid OpenPGP message before saving
- Check application rules on MetadataPrivateKeysTable for constraints the payload violates
Defensive patterns
Strategy: validation
Validate before calling
$encrypted = $openpgp->encrypt($clearText, true);
if (!is_string($encrypted) || $encrypted === '') {
throw new RuntimeException('Empty encrypted payload');
} Try / catch
try {
$shareService->shareMetadataKeysWithUser($user);
} catch (ValidationException $e) {
$errors = $e->getEntity()?->getErrors(); // inspect failing field
} Prevention
- Enable debug mode to log entity errors during development
- Assert encrypted payloads are non-empty valid OpenPGP messages
- Re-check table application rules when upgrading the metadata plugin
When it happens
Trigger: shareMetadataKeyWithUser() builds newEntity([...]) for MetadataPrivateKey; newEntity has errors, or checkRules() fails, e.g. the encrypted message is empty or the armored data invalid.
Common situations: Encryption produced an empty/invalid payload because of a broken user key; rules rejecting data not matching the expected OpenPGP message format; debug mode logs the exact errors.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- A valid OpenPGP key must be provided.
- A valid OpenPGP key must be provided.
- Could not save the account recovery private key.
- Could not validate key revocation.
- Could not validate message data.
AI-assisted analysis of passbolt/passbolt_api@31c1bbc10f (2026-09-17).
Data as JSON: /api/errors/9e72e0771c94e446.
Report an issue: GitHub.
Appendix: source
Thrown at plugins/PassboltCe/Metadata/src/Service/MetadataKeyShareDefaultService.php:118
try {
/** @var \Passbolt\Metadata\Model\Entity\MetadataPrivateKey $userMetadataPrivateKey */
$userMetadataPrivateKey = $metadataPrivateKeysTable->newEntity([
'metadata_key_id' => $serverMetadataPrivateKey->metadata_key_id,
'user_id' => $user->id,
'data' => $secret,
], [
'accessibleFields' => [
'metadata_key_id' => true,
'user_id' => true,
'data' => true,
],
]);
if (!empty($userMetadataPrivateKey->getErrors())) {
if (Configure::read('debug')) {
Log::error(json_encode($userMetadataPrivateKey->getErrors()));
}
$msg = __('The OpenPGP key data is not valid.');
throw new ValidationException($msg, $userMetadataPrivateKey, $metadataPrivateKeysTable);
}
if (!$metadataPrivateKeysTable->checkRules($userMetadataPrivateKey)) {
if (Configure::read('debug')) {
Log::error(json_encode($userMetadataPrivateKey->getErrors()));
}
$msg = __('The OpenPGP key data is not valid.');
throw new ValidationException($msg, $userMetadataPrivateKey, $metadataPrivateKeysTable);
}
} catch (Exception $exception) {
$msg = $exception->getMessage() . ' ';
$msg .= __('The data could not be validated.') . ' ';
$msg .= __('Metadata key could not be shared with user id: {0}.', $user->id);
throw new MetadataKeyShareException($msg, 500, $exception);
}
// Save private key entity for the user
try {
$metadataPrivateKeysTable->save($userMetadataPrivateKey, ['checkRules' => false]);View on GitHub (pinned to 31c1bbc10f)