passbolt/passbolt_api · error · FormValidationException
Could not validate the settings.
Error message
Could not validate the settings.
What it means
The metadata types settings payload submitted to the settings endpoint failed CakePHP form validation (MetadataTypesSettingsForm::execute returned false). A FormValidationException is raised carrying the form so the client can read per-field error messages. This is a 4xx-style input validation failure, not a server fault.
Solutions
- Read the form errors from the exception/HTTP 400 response body and fix the flagged fields.
- Compare the payload against the current MetadataTypesSettingsForm rules for your passbolt version.
- Fetch the current settings via GET and modify only known fields instead of posting a stale full document.
- Validate the JSON offline (run the form's execute() in a test/shell) before saving.
Example fix
// before (missing required field)
$settings = ['default_resource_types' => ['v5-default']];
$service->assert($settings);
// after (provide all required keys per form schema)
$settings = [
'default_resource_types' => ['v5-default'],
'default_folder_type' => 'v5',
'default_item_type' => 'v5',
];
$service->assert($settings); Defensive patterns
Strategy: validation
Validate before calling
$form = new \Passbolt\Metadata\Form\MetadataTypesSettingsForm();
if (!$form->execute($payload)) {
// fix $form->getErrors() before calling the service
} Try / catch
try {
$service->assert($data);
} catch (\App\Error\Exception\FormValidationException $e) {
$errors = $e->getForm()->getErrors(); // show per-field errors to the caller
} Prevention
- GET current settings first and patch them instead of posting a full stale document
- Keep API client payloads in sync with the passbolt version's form schema
- Validate payloads with MetadataTypesSettingsForm in tests before deploying automation
When it happens
Trigger: POST/PUT to the metadata types settings API with a payload missing required keys (e.g. default_resource_types / default_folder_type / default_item_type entries), containing unknown keys, or with wrong-typed values (e.g. string UUID where a valid UUID enum is expected).
Common situations: Admin UI or automation scripts sending outdated settings shapes after a passbolt upgrade; hand-crafted JSON missing newly required fields; passing nulls for fields the form marks required.
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
- The supplied email notification settings are not valid
- Could not validate settings.
- Could not validate the metadata key data.
- Could not validate the metadata key data.
- Could not validate the MFA policies settings.
AI-assisted analysis of passbolt/passbolt_api@31c1bbc10f (2026-09-17).
Data as JSON: /api/errors/4a3e53770db7ccdd.
Report an issue: GitHub.
Appendix: source
Thrown at plugins/PassboltCe/Metadata/src/Service/MetadataTypesSettingsAssertService.php:42
use Passbolt\Metadata\Model\Dto\MetadataTypesSettingsDto;
class MetadataTypesSettingsAssertService
{
use LocatorAwareTrait;
/**
* Validates the setting and return them
*
* @param array $data untrusted input
* @return \Passbolt\Metadata\Model\Dto\MetadataTypesSettingsDto dto
* @throws \App\Error\Exception\FormValidationException if the data does not validate
* @throws \App\Error\Exception\CustomValidationException if not active metadata key is found in DB and v5 is enabled
*/
public function assert(array $data): MetadataTypesSettingsDto
{
$form = new MetadataTypesSettingsForm();
if (!$form->execute($data)) {
throw new FormValidationException(__('Could not validate the settings.'), $form);
}
$dto = new MetadataTypesSettingsDto($form->getData());
// TODO "Build rules"
// Admin select a default resource version but all resource types are deleted for this version
return $dto;
}
/**
* @param \Passbolt\Metadata\Model\Dto\MetadataTypesSettingsDto $dto DTO
* @return void
* @throws \App\Error\Exception\CustomValidationException if no active metadata key is found in DB and v5 is enabled
*/
public function assertThatAnActiveMetadataKeyExistsWhenV5IsEnabled(MetadataTypesSettingsDto $dto): void
{
if (!$dto->isV5Enabled()) {View on GitHub (pinned to 31c1bbc10f)