{"record":{"id":"39c32956be382d2b","repo":"passbolt/passbolt_api","slug":"could-not-save-the-account-recovery-setting","errorCode":null,"errorMessage":"Could not save the account recovery setting.","messagePattern":"Could not save the account recovery setting\\.","errorType":"validation","errorClass":"ValidationException","httpStatus":400,"severity":"error","filePath":"plugins/PassboltEe/AccountRecovery/src/Service/Setup/AccountRecoverySetupCompleteService.php","lineNumber":180,"sourceCode":"        return is_array($this->request->getData(\n            'account_recovery_user_setting.account_recovery_private_key.account_recovery_private_key_passwords'\n        ));\n    }\n\n    /**\n     * Adds post-save validation on account recovery related data, in case the saving failed.\n     *\n     * @param \\App\\Model\\Entity\\User $user User entity\n     * @param array|null $saveOptions options\n     * @return \\App\\Model\\Entity\\User\n     */\n    protected function saveUserEntity(User $user, ?array $saveOptions = []): User\n    {\n        $user = parent::saveUserEntity($user, $saveOptions);\n\n        if ($this->isAccountRecoveryUserSettingProvided()) {\n            if ($user->get('account_recovery_user_setting')->hasErrors()) {\n                throw new ValidationException(\n                    'Could not save the account recovery setting.',\n                    $user->get('account_recovery_user_setting'),\n                    $this->AccountRecoveryUserSettings\n                );\n            }\n\n            if ($user->hasValue('account_recovery_private_key') && $user->get('account_recovery_private_key')->hasErrors()) { // phpcs:ignore\n                throw new ValidationException(\n                    'Could not save the account recovery private key.',\n                    $user->get('account_recovery_private_key'),\n                    $this->AccountRecoveryPrivateKeys\n                );\n            }\n        }\n\n        return $user;\n    }\n}","sourceCodeStart":162,"sourceCodeEnd":198,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/plugins/PassboltEe/AccountRecovery/src/Service/Setup/AccountRecoverySetupCompleteService.php#L162-L198","documentation":"Thrown when saving the user entity during account recovery setup completion succeeds for the user but the associated account_recovery_user_setting association fails validation. The ValidationException carries the entity errors and the AccountRecoveryUserSettings table so the client can render field-level errors.","triggerScenarios":"POST setup complete with an invalid account_recovery_user_setting value — e.g. a preference value not in the allowed enum ('approved'/'rejected' style values), malformed association data, or rule violations on the setting entity.","commonSituations":"Client sends an unexpected user setting string; request crafted by custom API scripts with wrong setting shape; concurrent setting rows violating unique constraints; older extension posting deprecated setting values.","solutions":["Inspect the errors array in the 400 response body to see which field of the account recovery setting failed validation","Send only supported account recovery user setting values (e.g. use the exact payload the web extension produces)","Update the browser extension to the latest version so it posts current setting formats","Check the AccountRecoveryUserSettings validation rules/table associations for custom modifications in your deployment"],"exampleFix":"// before\nbody = { account_recovery_user_setting: { status: 'ok' } }; // invalid value\n// after\nbody = { account_recovery_user_setting: { status: 'approved' } }; // supported enum value","handlingStrategy":"try-catch","validationCode":"const VALID_SETTINGS = ['approved', 'rejected'];\nif (payload.account_recovery_user_setting &&\n    !VALID_SETTINGS.includes(payload.account_recovery_user_setting.status)) {\n  throw new Error('Invalid account recovery user setting');\n}","typeGuard":"const isValidUserSetting = (s) => s != null && typeof s === 'object' && ['approved','rejected'].includes(s.status);","tryCatchPattern":"try {\n  await setupComplete(payload);\n} catch (e) {\n  if (e.name === 'ValidationException' && e.errors?.account_recovery_user_setting) {\n    showFieldErrors(e.errors.account_recovery_user_setting);\n  } else { throw e; }\n}","preventionTips":["Read and display the errors object from ValidationException responses","Only send setting values produced by the official web extension","Validate setting payloads against the AccountRecoveryUserSettings rules in custom integrations","Test the setup complete flow after upgrading server or extension versions"],"tags":["account-recovery","validation","entity-save","http-400"],"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"}