passbolt/passbolt_api · error · FormValidationException
Could not validate the MFA policies settings.
Error message
Could not validate the MFA policies settings.
What it means
The POST body for MFA policy settings is validated by MfaPoliciesSettingsForm (e.g. 'policy' must be an allowed value like 'mandatory'/'opt-out' or 'opt-in'). When $form->execute($requestData) fails, a FormValidationException with this message is thrown, carrying the form's errors.
Solutions
- Inspect the FormValidationException errors to see which field failed
- Send only the supported 'policy' value ('mandatory' or 'opt-out' depending on edition/version)
- Ensure the request body is JSON with content-type application/json and contains the 'policy' key
Example fix
// before
{"mfaPolicy": "enforced"}
// after
{"policy": "mandatory"} Defensive patterns
Strategy: validation
Validate before calling
$data = $this->getRequest()->getData();
$form = new MfaPoliciesSettingsForm();
if (!$form->execute($data)) {
$errors = $form->getErrors(); // inspect before proceeding
} Try / catch
try {
$resp = $client->post('/mfa/policies/settings.json', ['policy' => 'mandatory']);
} catch (FormValidationException $e) {
$errors = $e->getForm()->getErrors();
} Prevention
- Only send the documented 'policy' enum values
- Send JSON with proper content-type header
- Consult the form/DTO definition for accepted fields before integrating
When it happens
Trigger: POST /mfa/policies/settings.json with missing or invalid fields — e.g. policy not in the allowed enum, unexpected extra types, or empty request data.
Common situations: API clients sending 'policy' values other than the supported enum, omitting the policy key, or sending JSON not parsed into form fields.
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
- Could not validate settings.
- Could not validate the metadata key data.
- Could not validate the metadata key data.
- Could not validate the password policies settings.
- Could not validate the settings.
AI-assisted analysis of passbolt/passbolt_api@31c1bbc10f (2026-09-17).
Data as JSON: /api/errors/e519d8d806083ac9.
Report an issue: GitHub.
Appendix: source
Thrown at plugins/PassboltEe/MfaPolicies/src/Controller/MfaPoliciesSettingsSetController.php:47
/**
* Create/update MFA policies settings.
*
* @return void
*/
public function post()
{
if (!$this->User->isAdmin()) {
throw new ForbiddenException(
__('Only administrators are allowed to create/update MFA policies settings.')
);
}
$requestData = $this->getRequest()->getData();
$form = new MfaPoliciesSettingsForm();
if (!$form->execute($requestData)) {
throw new FormValidationException(__('Could not validate the MFA policies settings.'), $form);
}
$setSettingsService = new MfaPoliciesSetSettingsService();
$mfaPolicySettingsDto = MfaPolicySettings::createFromArray([
'policy' => $form->getData('policy'),
'remember_me_for_a_month' => $form->getData('remember_me_for_a_month'),
]);
$settings = $setSettingsService->createOrUpdate($this->User->getExtendAccessControl(), $mfaPolicySettingsDto);
$this->success(__('The operation was successful.'), $settings);
}
}
View on GitHub (pinned to 31c1bbc10f)