{"record":{"id":"0fce1ac5c586fff8","repo":"passbolt/passbolt_api","slug":"could-not-validate-the-password-policies-settings","errorCode":null,"errorMessage":"Could not validate the password policies settings.","messagePattern":"Could not validate the password policies settings\\.","errorType":"validation","errorClass":"FormValidationException","httpStatus":400,"severity":"error","filePath":"plugins/PassboltCe/PasswordPolicies/src/Service/PasswordPoliciesGetSettingsService.php","lineNumber":38,"sourceCode":"use App\\Error\\Exception\\FormValidationException;\nuse Cake\\Core\\Configure;\nuse Passbolt\\PasswordGenerator\\PasswordGeneratorPlugin;\nuse Passbolt\\PasswordPolicies\\Form\\PasswordPoliciesSettingsForm;\nuse Passbolt\\PasswordPolicies\\Model\\Dto\\PasswordPoliciesSettingsDto;\nuse Passbolt\\PasswordPolicies\\PasswordPoliciesPlugin;\n\nclass PasswordPoliciesGetSettingsService implements PasswordPoliciesGetSettingsInterface\n{\n    /**\n     * @inheritDoc\n     */\n    public function get(): PasswordPoliciesSettingsDto\n    {\n        $passwordPoliciesSettingsDto = $this->getSettingsFromFileOrEnv();\n\n        $form = new PasswordPoliciesSettingsForm();\n        if (!$form->execute($passwordPoliciesSettingsDto->toArray())) {\n            throw new FormValidationException(__('Could not validate the password policies settings.'), $form);\n        }\n\n        return $passwordPoliciesSettingsDto;\n    }\n\n    /**\n     * Get password policies from file or environment variables.\n     *\n     * @return \\Passbolt\\PasswordPolicies\\Model\\Dto\\PasswordPoliciesSettingsDto\n     */\n    private function getSettingsFromFileOrEnv(): PasswordPoliciesSettingsDto\n    {\n        $settingsSource = $this->getSettingsSource();\n        $defaultPasswordGenerator = $this->getPasswordGeneratorFromSource($settingsSource);\n        $passwordPoliciesSettingsData = [\n            'source' => $settingsSource,\n            'default_generator' => $defaultPasswordGenerator,\n        ];","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/plugins/PassboltCe/PasswordPolicies/src/Service/PasswordPoliciesGetSettingsService.php#L20-L56","documentation":"Thrown by PasswordPoliciesGetSettingsService::get() when the password policies settings loaded from file or environment fail validation against PasswordPoliciesSettingsForm. The service refuses to return settings that do not conform to the expected schema, so a broken or hand-edited config is surfaced instead of silently propagated.","triggerScenarios":"Calling get() (e.g. via the password policies settings GET endpoint or import) when the settings file/env values are missing required keys, have wrong types, or contain out-of-range policy values.","commonSituations":"Operators hand-editing config/password-policies.php with invalid values (e.g. non-numeric entropy settings, malformed generator options), upgrading passbolt when the settings schema changed and old files no longer validate, or env-var overrides with bad values.","solutions":["Inspect the form errors: catch FormValidationException and read getErrors()/the form errors to see which fields failed.","Fix the invalid values in the password policies settings file or environment variables and retry.","Regenerate a valid settings file from a working installation or re-save settings via the admin UI.","Verify the plugin/config version matches the running passbolt version after upgrades."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"$dto = $settingsDto->toArray();\n$form = new PasswordPoliciesSettingsForm();\nif (!$form->validate($dto)) {\n    error_log(print_r($form->getErrors(), true));\n}","typeGuard":null,"tryCatchPattern":"try {\n    $settings = $service->get();\n} catch (FormValidationException $e) {\n    $errors = $e->getForm()->getErrors();\n    // log/repair settings\n}","preventionTips":["Never hand-edit the password policies config without validating against the form schema.","Re-validate settings after passbolt upgrades.","Use the admin UI to generate settings rather than writing files manually.","Keep env overrides consistent with expected types (numeric/boolean)."],"tags":["php","cakephp","validation","configuration","passbolt"],"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"}