passbolt/passbolt_api · error · FormValidationException

Could not validate the self registration settings.

Error message

Could not validate the self registration settings.

What it means

Thrown by SelfRegistrationSetSettingsService::saveSettings when the submitted payload fails validation against the self-registration form. A FormValidationException is raised carrying the form's error list; it is a client-facing validation error, not a server fault.

Solutions

  1. Inspect the FormValidationException errors array in the response body and correct the offending fields.
  2. Ensure `providers` only contains allowed values and that `email_domains` is a non-empty array of valid domains when provider is email.
  3. Re-send the request with only the documented allowed fields.

Example fix

// before
PUT /self-registration.json {"providers":["email"],"email_domains":[]}

// after
PUT /self-registration.json {"providers":["email"],"email_domains":["mycompany.com"]}
Defensive patterns

Strategy: validation

Validate before calling

$providers = ['email', 'allow-signups']; // allowed values
if (!isset($data['providers']) || array_diff($data['providers'], $providers)) {
    throw new InvalidArgumentException('providers contains unsupported values');
}
if (in_array('email', $data['providers']) && empty($data['email_domains'])) {
    throw new InvalidArgumentException('email_domains is required');
}

Try / catch

try {
    $result = $service->saveSettings($data);
} catch (FormValidationException $e) {
    $errors = $e->getForm()->getErrors(); // show field-level errors to the caller
}

Prevention

When it happens

Trigger: PUT/POST /self-registration.json with invalid data: unknown provider in `providers`, empty or invalid `email_domains`, extraneous fields, or malformed nested values.

Common situations: API clients sending provider values like 'token' or 'open' that current rules disallow; missing email_domains when provider is 'email'; scripts posting raw user input without pre-validation.

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

Appendix: source

Thrown at plugins/PassboltCe/SelfRegistration/src/Service/SelfRegistrationSetSettingsService.php:52

    /**
     * @param \App\Utility\UserAccessControl $uac UAC
     */
    public function __construct(UserAccessControl $uac)
    {
        $this->uac = $uac;
    }

    /**
     * @param array $data data in the payload
     * @return array
     */
    public function saveSettings(array $data): array
    {
        $form = $this->getFormFromData($data);

        if (!$form->execute($data)) {
            throw new FormValidationException(
                __('Could not validate the self registration settings.'),
                $form
            );
        }

        // @todo [FYI] see how the json content is handled by MfaPolicies and schedule a ticket to take care of it.
        $value = json_encode($form->getData());

        /** @var \App\Model\Table\OrganizationSettingsTable $OrganizationSettings */
        $OrganizationSettings = TableRegistry::getTableLocator()->get('OrganizationSettings');

        $setting = $OrganizationSettings->createOrUpdateSetting(
            self::USER_SELF_REGISTRATION_SETTINGS_PROPERTY_NAME,
            $value,
            $this->uac
        );
        $renderedSettings = $this->getRenderedValue($setting, $form);

View on GitHub (pinned to 31c1bbc10f)