{"record":{"id":"c018a0e2f26ddbcf","repo":"passbolt/passbolt_api","slug":"could-not-validate-the-self-registration-settings","errorCode":null,"errorMessage":"Could not validate the self registration settings.","messagePattern":"Could not validate the self registration settings\\.","errorType":"validation","errorClass":"FormValidationException","httpStatus":400,"severity":"error","filePath":"plugins/PassboltCe/SelfRegistration/src/Service/SelfRegistrationSetSettingsService.php","lineNumber":52,"sourceCode":"\n    /**\n     * @param \\App\\Utility\\UserAccessControl $uac UAC\n     */\n    public function __construct(UserAccessControl $uac)\n    {\n        $this->uac = $uac;\n    }\n\n    /**\n     * @param array $data data in the payload\n     * @return array\n     */\n    public function saveSettings(array $data): array\n    {\n        $form = $this->getFormFromData($data);\n\n        if (!$form->execute($data)) {\n            throw new FormValidationException(\n                __('Could not validate the self registration settings.'),\n                $form\n            );\n        }\n\n        // @todo [FYI] see how the json content is handled by MfaPolicies and schedule a ticket to take care of it.\n        $value = json_encode($form->getData());\n\n        /** @var \\App\\Model\\Table\\OrganizationSettingsTable $OrganizationSettings */\n        $OrganizationSettings = TableRegistry::getTableLocator()->get('OrganizationSettings');\n\n        $setting = $OrganizationSettings->createOrUpdateSetting(\n            self::USER_SELF_REGISTRATION_SETTINGS_PROPERTY_NAME,\n            $value,\n            $this->uac\n        );\n        $renderedSettings = $this->getRenderedValue($setting, $form);\n","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/plugins/PassboltCe/SelfRegistration/src/Service/SelfRegistrationSetSettingsService.php#L34-L70","documentation":"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.","triggerScenarios":"PUT/POST /self-registration.json with invalid data: unknown provider in `providers`, empty or invalid `email_domains`, extraneous fields, or malformed nested values.","commonSituations":"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.","solutions":["Inspect the FormValidationException errors array in the response body and correct the offending fields.","Ensure `providers` only contains allowed values and that `email_domains` is a non-empty array of valid domains when provider is email.","Re-send the request with only the documented allowed fields."],"exampleFix":"// before\nPUT /self-registration.json {\"providers\":[\"email\"],\"email_domains\":[]}\n\n// after\nPUT /self-registration.json {\"providers\":[\"email\"],\"email_domains\":[\"mycompany.com\"]}","handlingStrategy":"validation","validationCode":"$providers = ['email', 'allow-signups']; // allowed values\nif (!isset($data['providers']) || array_diff($data['providers'], $providers)) {\n    throw new InvalidArgumentException('providers contains unsupported values');\n}\nif (in_array('email', $data['providers']) && empty($data['email_domains'])) {\n    throw new InvalidArgumentException('email_domains is required');\n}","typeGuard":null,"tryCatchPattern":"try {\n    $result = $service->saveSettings($data);\n} catch (FormValidationException $e) {\n    $errors = $e->getForm()->getErrors(); // show field-level errors to the caller\n}","preventionTips":["Validate payloads client-side against the current self-registration schema.","Only send documented fields; avoid deprecated provider values.","Keep API payloads in sync with the passbolt version you run.","Log full form errors on failure rather than just the message."],"tags":["validation","api","configuration","cakephp"],"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"}