{"record":{"id":"4cfd9d93f6c9fbd6","repo":"passbolt/passbolt_api","slug":"could-not-validate-the-password-policies-settings-4cfd9d","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/PassboltEe/PasswordPoliciesUpdate/src/Service/PasswordPoliciesUpdateGetSettingsService.php","lineNumber":49,"sourceCode":"    /**\n     * @inheritDoc\n     */\n    public function get(): PasswordPoliciesSettingsDto\n    {\n        /** @var \\Passbolt\\PasswordPoliciesUpdate\\Model\\Table\\PasswordPoliciesSettingsTable $passwordPoliciesSettingsTable */\n        $passwordPoliciesSettingsTable = $this->fetchTable('Passbolt/PasswordPoliciesUpdate.PasswordPoliciesSettings'); // phpcs:ignore\n\n        /** @var \\Passbolt\\PasswordPoliciesUpdate\\Model\\Entity\\PasswordPoliciesSetting|null $passwordPoliciesSettings */\n        $passwordPoliciesSettings = $passwordPoliciesSettingsTable->find()->first();\n\n        // Fallback to default settings if no data in database\n        if (is_null($passwordPoliciesSettings)) {\n            return parent::get();\n        }\n\n        $form = new PasswordPoliciesSettingsForm();\n        if (!$form->execute($passwordPoliciesSettings->value)) {\n            throw new FormValidationException(__('Could not validate the password policies settings.'), $form);\n        }\n\n        return PasswordPoliciesUpdateSettingsDto::createFromEntity($passwordPoliciesSettings);\n    }\n}\n","sourceCodeStart":31,"sourceCodeEnd":55,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/plugins/PassboltEe/PasswordPoliciesUpdate/src/Service/PasswordPoliciesUpdateGetSettingsService.php#L31-L55","documentation":"PasswordPoliciesUpdateGetSettingsService::get validates the stored organization settings entity against PasswordPoliciesSettingsForm before returning it. If the persisted settings value fails form validation, this FormValidationException is thrown, indicating corrupted or schema-incompatible stored settings (e.g. from an older plugin version).","triggerScenarios":"GET request for the password policies settings when the stored organization-settings row contains fields that fail PasswordPoliciesSettingsForm rules (missing required keys, wrong types, out-of-range values).","commonSituations":"Settings written by an older plugin version before a rule/field change; manual edits to organization settings; partially failed settings save leaving invalid JSON in the DB.","solutions":["Re-save the password policies settings through the settings update endpoint/form so the stored value is revalidated and rewritten","Inspect the organization_settings row for the PasswordPolicies plugin in the DB and fix/remove the invalid entry (backup first)","Run the form validation locally against the stored value to identify the offending field, then update client/settings to comply"],"exampleFix":"// before (stored invalid settings)\n{\"generator\": {\"minLength\": \"abc\"}}\n\n// after\n{\"generator\": {\"min_length\": 12, \"max_length\": 128}} // then re-save via settings API","handlingStrategy":"try-catch","validationCode":"$stored = $settings->value;\n$form = new PasswordPoliciesSettingsForm();\nif (!$form->execute($stored)) {\n    // invalid stored settings: resave defaults or surface to admin\n}","typeGuard":null,"tryCatchPattern":"try {\n    $dto = $settingsService->get($uac);\n} catch (FormValidationException $e) {\n    // fall back to default settings and alert admin to re-save policies\n    $dto = PasswordPoliciesUpdateSettingsDto::default();\n}","preventionTips":["Re-save settings through the form after plugin upgrades to revalidate stored values","Validate settings payloads with the form before persisting","Monitor organization_settings rows for unexpected manual edits"],"tags":["passbolt","password-policies","settings","form-validation"],"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"}