{"record":{"id":"9e72e0771c94e446","repo":"passbolt/passbolt_api","slug":"the-openpgp-key-data-is-not-valid","errorCode":null,"errorMessage":"The OpenPGP key data is not valid.","messagePattern":"The OpenPGP key data is not valid\\.","errorType":"validation","errorClass":"ValidationException","httpStatus":400,"severity":"error","filePath":"plugins/PassboltCe/Metadata/src/Service/MetadataKeyShareDefaultService.php","lineNumber":118,"sourceCode":"        try {\n            /** @var \\Passbolt\\Metadata\\Model\\Entity\\MetadataPrivateKey $userMetadataPrivateKey */\n            $userMetadataPrivateKey = $metadataPrivateKeysTable->newEntity([\n                'metadata_key_id' => $serverMetadataPrivateKey->metadata_key_id,\n                'user_id' => $user->id,\n                'data' => $secret,\n            ], [\n                'accessibleFields' => [\n                    'metadata_key_id' => true,\n                    'user_id' => true,\n                    'data' => true,\n                ],\n            ]);\n            if (!empty($userMetadataPrivateKey->getErrors())) {\n                if (Configure::read('debug')) {\n                    Log::error(json_encode($userMetadataPrivateKey->getErrors()));\n                }\n                $msg = __('The OpenPGP key data is not valid.');\n                throw new ValidationException($msg, $userMetadataPrivateKey, $metadataPrivateKeysTable);\n            }\n            if (!$metadataPrivateKeysTable->checkRules($userMetadataPrivateKey)) {\n                if (Configure::read('debug')) {\n                    Log::error(json_encode($userMetadataPrivateKey->getErrors()));\n                }\n                $msg = __('The OpenPGP key data is not valid.');\n                throw new ValidationException($msg, $userMetadataPrivateKey, $metadataPrivateKeysTable);\n            }\n        } catch (Exception $exception) {\n            $msg = $exception->getMessage() . ' ';\n            $msg .= __('The data could not be validated.') . ' ';\n            $msg .= __('Metadata key could not be shared with user id: {0}.', $user->id);\n            throw new MetadataKeyShareException($msg, 500, $exception);\n        }\n\n        // Save private key entity for the user\n        try {\n            $metadataPrivateKeysTable->save($userMetadataPrivateKey, ['checkRules' => false]);","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/plugins/PassboltCe/Metadata/src/Service/MetadataKeyShareDefaultService.php#L100-L136","documentation":"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.","triggerScenarios":"shareMetadataKeyWithUser() builds newEntity([...]) for MetadataPrivateKey; newEntity has errors, or checkRules() fails, e.g. the encrypted message is empty or the armored data invalid.","commonSituations":"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.","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"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"$encrypted = $openpgp->encrypt($clearText, true);\nif (!is_string($encrypted) || $encrypted === '') {\n    throw new RuntimeException('Empty encrypted payload');\n}","typeGuard":null,"tryCatchPattern":"try {\n    $shareService->shareMetadataKeysWithUser($user);\n} catch (ValidationException $e) {\n    $errors = $e->getEntity()?->getErrors(); // inspect failing field\n}","preventionTips":["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"],"tags":["openpgp","validation","metadata-private-key"],"backgroundTag":"schema-validation-failed","analyzedSha":"31c1bbc10f32808a607fa9bd81891e898779c0bc","analyzedAt":"2026-09-17T00:04:38.960Z","contentChangedAt":"2026-09-17T00:04:38.960Z","schemaVersion":2},"datasetVersion":"2026-09-22T16:17:23.217Z"}