passbolt/passbolt_api · error · FormValidationException

Could not validate the password policies settings.

Error message

Could not validate the password policies settings.

What it means

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.

Solutions

  1. Inspect the form errors: catch FormValidationException and read getErrors()/the form errors to see which fields failed.
  2. Fix the invalid values in the password policies settings file or environment variables and retry.
  3. Regenerate a valid settings file from a working installation or re-save settings via the admin UI.
  4. Verify the plugin/config version matches the running passbolt version after upgrades.
Defensive patterns

Strategy: validation

Validate before calling

$dto = $settingsDto->toArray();
$form = new PasswordPoliciesSettingsForm();
if (!$form->validate($dto)) {
    error_log(print_r($form->getErrors(), true));
}

Try / catch

try {
    $settings = $service->get();
} catch (FormValidationException $e) {
    $errors = $e->getForm()->getErrors();
    // log/repair settings
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of passbolt/passbolt_api@31c1bbc10f (2026-09-17). Data as JSON: /api/errors/0fce1ac5c586fff8. Report an issue: GitHub.

Appendix: source

Thrown at plugins/PassboltCe/PasswordPolicies/src/Service/PasswordPoliciesGetSettingsService.php:38

use App\Error\Exception\FormValidationException;
use Cake\Core\Configure;
use Passbolt\PasswordGenerator\PasswordGeneratorPlugin;
use Passbolt\PasswordPolicies\Form\PasswordPoliciesSettingsForm;
use Passbolt\PasswordPolicies\Model\Dto\PasswordPoliciesSettingsDto;
use Passbolt\PasswordPolicies\PasswordPoliciesPlugin;

class PasswordPoliciesGetSettingsService implements PasswordPoliciesGetSettingsInterface
{
    /**
     * @inheritDoc
     */
    public function get(): PasswordPoliciesSettingsDto
    {
        $passwordPoliciesSettingsDto = $this->getSettingsFromFileOrEnv();

        $form = new PasswordPoliciesSettingsForm();
        if (!$form->execute($passwordPoliciesSettingsDto->toArray())) {
            throw new FormValidationException(__('Could not validate the password policies settings.'), $form);
        }

        return $passwordPoliciesSettingsDto;
    }

    /**
     * Get password policies from file or environment variables.
     *
     * @return \Passbolt\PasswordPolicies\Model\Dto\PasswordPoliciesSettingsDto
     */
    private function getSettingsFromFileOrEnv(): PasswordPoliciesSettingsDto
    {
        $settingsSource = $this->getSettingsSource();
        $defaultPasswordGenerator = $this->getPasswordGeneratorFromSource($settingsSource);
        $passwordPoliciesSettingsData = [
            'source' => $settingsSource,
            'default_generator' => $defaultPasswordGenerator,
        ];

View on GitHub (pinned to 31c1bbc10f)