passbolt/passbolt_api · error · FormValidationException

Could not validate the password policies settings.

Error message

Could not validate the password policies settings.

What it means

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).

Solutions

  1. Re-save the password policies settings through the settings update endpoint/form so the stored value is revalidated and rewritten
  2. Inspect the organization_settings row for the PasswordPolicies plugin in the DB and fix/remove the invalid entry (backup first)
  3. Run the form validation locally against the stored value to identify the offending field, then update client/settings to comply

Example fix

// before (stored invalid settings)
{"generator": {"minLength": "abc"}}

// after
{"generator": {"min_length": 12, "max_length": 128}} // then re-save via settings API
Defensive patterns

Strategy: try-catch

Validate before calling

$stored = $settings->value;
$form = new PasswordPoliciesSettingsForm();
if (!$form->execute($stored)) {
    // invalid stored settings: resave defaults or surface to admin
}

Try / catch

try {
    $dto = $settingsService->get($uac);
} catch (FormValidationException $e) {
    // fall back to default settings and alert admin to re-save policies
    $dto = PasswordPoliciesUpdateSettingsDto::default();
}

Prevention

When it happens

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

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

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/4cfd9d93f6c9fbd6. Report an issue: GitHub.

Appendix: source

Thrown at plugins/PassboltEe/PasswordPoliciesUpdate/src/Service/PasswordPoliciesUpdateGetSettingsService.php:49

    /**
     * @inheritDoc
     */
    public function get(): PasswordPoliciesSettingsDto
    {
        /** @var \Passbolt\PasswordPoliciesUpdate\Model\Table\PasswordPoliciesSettingsTable $passwordPoliciesSettingsTable */
        $passwordPoliciesSettingsTable = $this->fetchTable('Passbolt/PasswordPoliciesUpdate.PasswordPoliciesSettings'); // phpcs:ignore

        /** @var \Passbolt\PasswordPoliciesUpdate\Model\Entity\PasswordPoliciesSetting|null $passwordPoliciesSettings */
        $passwordPoliciesSettings = $passwordPoliciesSettingsTable->find()->first();

        // Fallback to default settings if no data in database
        if (is_null($passwordPoliciesSettings)) {
            return parent::get();
        }

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

        return PasswordPoliciesUpdateSettingsDto::createFromEntity($passwordPoliciesSettings);
    }
}

View on GitHub (pinned to 31c1bbc10f)