{"record":{"id":"1250b7e0ce2c7c63","repo":"passbolt/passbolt_api","slug":"the-account-recovery-private-key-is-not-valid","errorCode":null,"errorMessage":"The account recovery private key is not valid.","messagePattern":"The account recovery private key is not valid\\.","errorType":"validation","errorClass":"ValidationException","httpStatus":422,"severity":"error","filePath":"plugins/PassboltEe/AccountRecovery/src/Model/Table/AccountRecoveryPrivateKeysTable.php","lineNumber":186,"sourceCode":"        /** @var \\Passbolt\\AccountRecovery\\Model\\Entity\\AccountRecoveryPrivateKey $privateKeyEntity */\n        $privateKeyEntity = $this->newEntity([\n            'user_id' => $userId,\n            'data' => $privateKey['data'] ?? [],\n            'created_by' => $userId,\n            'modified_by' => $userId,\n        ], [\n            'accessibleFields' => [\n                'user_id' => true,\n                'data' => true,\n                'account_recovery_private_key_passwords' => true,\n                'created_by' => true,\n                'modified_by' => true,\n            ],\n        ]);\n\n        if ($privateKeyEntity->hasErrors()) {\n            $msg = __('The account recovery private key is not valid.');\n            throw new ValidationException($msg, $privateKeyEntity, $this);\n        }\n\n        return $privateKeyEntity;\n    }\n\n    /**\n     * Retrieves a list of cleanup methods (first-class callables) implemented by this table.\n     *\n     * @return array<int, callable> List of callables\n     */\n    public function getCleanupMethods(): array\n    {\n        return [\n            $this->cleanupHardDeletedUsers(...),\n            $this->cleanupSoftDeletedUsers(...),\n        ];\n    }\n}","sourceCodeStart":168,"sourceCodeEnd":204,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/plugins/PassboltEe/AccountRecovery/src/Model/Table/AccountRecoveryPrivateKeysTable.php#L168-L204","documentation":"A ValidationException thrown when the account recovery private key entity built in buildAndValidateEntity fails the table's validation rules. The offending entity is attached, exposing field-level errors (e.g. invalid armored key data or missing user_id).","triggerScenarios":"Storing a user's recovery private key with invalid/malformed armored_key data, a missing or invalid user_id, or values violating column constraints.","commonSituations":"Client uploads a key whose armor is corrupted; wrong user association during response creation; old client producing a field name the current schema doesn't accept.","solutions":["Inspect the entity errors attached to the ValidationException.","Verify the armored private key is complete and well-formed before submitting.","Confirm the payload targets the correct user_id.","Upgrade the client so field names match the server schema."],"exampleFix":"// before\n\"armored_key\": PgpMessage.read(armoredKey).armor // may be undefined on parse failure\n// after\nif (!armoredKey || !armoredKey.includes('-----END PGP PRIVATE KEY BLOCK-----')) throw new Error('invalid key');\nawait post('/account-recovery/private-keys', {armored_key: armoredKey});","handlingStrategy":"validation","validationCode":"if (!armoredKey?.includes('-----END PGP PRIVATE KEY BLOCK-----')) throw new Error('armored private key incomplete');","typeGuard":"function isArmoredPrivateKey(v) { return typeof v === 'string' && v.includes('-----BEGIN PGP PRIVATE KEY BLOCK-----') && v.includes('-----END PGP PRIVATE KEY BLOCK-----'); }","tryCatchPattern":"try { await api.submitRecoveryPrivateKey({armored_key, user_id}); } catch (e) { if (e.body && e.body.account_recovery_private_key) { reportFieldErrors(e.body.account_recovery_private_key); } else { throw e; } }","preventionTips":["Validate full armor block before submission.","Verify parseability with your OpenPGP library first.","Ensure the user_id is a valid UUID of an existing user.","Sync client field names with the server schema."],"tags":["validation","pgp","account-recovery","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-21T04:17:39.646Z"}