{"record":{"id":"d84dcc8fae8d4ffa","repo":"passbolt/passbolt_api","slug":"could-not-validate-the-settings-d84dcc","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/SecretRevisions/src/Service/SecretRevisionsSettingsAssertService.php","lineNumber":39,"sourceCode":"use Passbolt\\SecretRevisions\\Form\\SecretRevisionsSettingsForm;\nuse Passbolt\\SecretRevisions\\Model\\Dto\\SecretRevisionsSettingsDto;\n\nclass SecretRevisionsSettingsAssertService\n{\n    use LocatorAwareTrait;\n\n    /**\n     * Validate secret revision settings.\n     *\n     * @param array $data Data to assert.\n     * @return \\Passbolt\\SecretRevisions\\Model\\Dto\\SecretRevisionsSettingsDto DTO.\n     * @throws \\App\\Error\\Exception\\FormValidationException Data does not validate.\n     */\n    public function assert(array $data): SecretRevisionsSettingsDto\n    {\n        $form = new SecretRevisionsSettingsForm();\n        if (!$form->execute($data)) {\n            throw new FormValidationException(__('Could not validate the settings.'), $form);\n        }\n\n        return SecretRevisionsSettingsDto::fromArray($form->getData());\n    }\n}\n","sourceCodeStart":21,"sourceCodeEnd":45,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/plugins/PassboltCe/SecretRevisions/src/Service/SecretRevisionsSettingsAssertService.php#L21-L45","documentation":"Thrown by SecretRevisionsSettingsAssertService::assert when the SecretRevisionsSettingsForm does not validate the submitted settings payload. FormValidationException carries the form so callers can read per-field errors. The plugin requires settings to pass its declared schema before they are stored.","triggerScenarios":"POST/PUT to the secret revisions settings endpoints with a payload that fails SecretRevisionsSettingsForm rules (e.g. missing required keys, invalid values for thresholds like maximum_revisions, wrong types).","commonSituations":"API clients sending snake_case vs camelCase keys incorrectly; omitting required fields when updating only part of the settings; older clients sending fields removed in a newer plugin version.","solutions":["Call the GET settings endpoint or inspect form errors to see the exact failing fields","Ensure all required keys (e.g. the plugin-enabled flag and numeric options) are present and correctly typed","Resend the full settings payload rather than a partial patch","Check the SecretRevisionsSettingsForm rules for the expected structure"],"exampleFix":"// before\n$service->assert(['maximum_revisions' => 'ten']);\n// after\n$service->assert(['maximum_revisions' => 10]);","handlingStrategy":"validation","validationCode":"const required = ['maximum_revisions']; // per SecretRevisionsSettingsForm\nconst payloadOk = typeof payload === 'object' && required.every(k => k in payload);\nif (!payloadOk) throw new Error('settings payload missing required fields');","typeGuard":"if (!is_array($data) || empty($data)) { throw new BadRequestException('Settings payload required'); }","tryCatchPattern":"try {\n    $dto = $assertService->assert($data);\n} catch (FormValidationException $e) {\n    $errors = $e->getForm()->getErrors(); // show per-field messages to the caller\n}","preventionTips":["Send the complete settings payload, not partial patches","Match key names exactly to the form definition","Test payloads against the form rules in a unit test","Check GET settings first to mirror the expected structure"],"tags":["validation","settings","form"],"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"}