{"record":{"id":"4a3e53770db7ccdd","repo":"passbolt/passbolt_api","slug":"could-not-validate-the-settings-4a3e53","errorCode":null,"errorMessage":"Could not validate the settings.","messagePattern":"Could not validate the settings\\.","errorType":"validation","errorClass":"FormValidationException","httpStatus":400,"severity":"error","filePath":"plugins/PassboltCe/Metadata/src/Service/MetadataTypesSettingsAssertService.php","lineNumber":42,"sourceCode":"use Passbolt\\Metadata\\Model\\Dto\\MetadataTypesSettingsDto;\n\nclass MetadataTypesSettingsAssertService\n{\n    use LocatorAwareTrait;\n\n    /**\n     * Validates the setting and return them\n     *\n     * @param array $data untrusted input\n     * @return \\Passbolt\\Metadata\\Model\\Dto\\MetadataTypesSettingsDto dto\n     * @throws \\App\\Error\\Exception\\FormValidationException if the data does not validate\n     * @throws \\App\\Error\\Exception\\CustomValidationException if not active metadata key is found in DB and v5 is enabled\n     */\n    public function assert(array $data): MetadataTypesSettingsDto\n    {\n        $form = new MetadataTypesSettingsForm();\n        if (!$form->execute($data)) {\n            throw new FormValidationException(__('Could not validate the settings.'), $form);\n        }\n\n        $dto = new MetadataTypesSettingsDto($form->getData());\n\n        // TODO \"Build rules\"\n        // Admin select a default resource version but all resource types are deleted for this version\n\n        return $dto;\n    }\n\n    /**\n     * @param \\Passbolt\\Metadata\\Model\\Dto\\MetadataTypesSettingsDto $dto DTO\n     * @return void\n     * @throws \\App\\Error\\Exception\\CustomValidationException if no active metadata key is found in DB and v5 is enabled\n     */\n    public function assertThatAnActiveMetadataKeyExistsWhenV5IsEnabled(MetadataTypesSettingsDto $dto): void\n    {\n        if (!$dto->isV5Enabled()) {","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/plugins/PassboltCe/Metadata/src/Service/MetadataTypesSettingsAssertService.php#L24-L60","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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."],"exampleFix":"// before (missing required field)\n$settings = ['default_resource_types' => ['v5-default']];\n$service->assert($settings);\n// after (provide all required keys per form schema)\n$settings = [\n    'default_resource_types' => ['v5-default'],\n    'default_folder_type' => 'v5',\n    'default_item_type' => 'v5',\n];\n$service->assert($settings);","handlingStrategy":"validation","validationCode":"$form = new \\Passbolt\\Metadata\\Form\\MetadataTypesSettingsForm();\nif (!$form->execute($payload)) {\n    // fix $form->getErrors() before calling the service\n}","typeGuard":null,"tryCatchPattern":"try {\n    $service->assert($data);\n} catch (\\App\\Error\\Exception\\FormValidationException $e) {\n    $errors = $e->getForm()->getErrors(); // show per-field errors to the caller\n}","preventionTips":["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"],"tags":["validation","settings","form-validation","metadata"],"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"}