{"record":{"id":"3ccac9bd8591f71b","repo":"passbolt/passbolt_api","slug":"could-not-validate-the-user-passphrase-policies-settings-3ccac9","errorCode":null,"errorMessage":"Could not validate the user passphrase policies settings.","messagePattern":"Could not validate the user passphrase policies settings\\.","errorType":"validation","errorClass":"FormValidationException","httpStatus":400,"severity":"error","filePath":"plugins/PassboltEe/UserPassphrasePolicies/src/Service/UserPassphrasePoliciesSetSettingsService.php","lineNumber":58,"sourceCode":"    /**\n     * Create user passphrase policy settings if not already present in DB or update the settings value if already exists.\n     *\n     * @param \\App\\Utility\\ExtendedUserAccessControl $uac Extended user access control.\n     * @param array $requestData Request data.\n     * @return \\Passbolt\\UserPassphrasePolicies\\Model\\Dto\\UserPassphrasePoliciesSettingsDto\n     * @throws \\Exception\n     */\n    public function createOrUpdate(ExtendedUserAccessControl $uac, array $requestData): UserPassphrasePoliciesSettingsDto // phpcs:ignore\n    {\n        if (!$uac->isAdmin()) {\n            throw new ForbiddenException(\n                __('Only administrators are allowed to create/update user passphrase policies settings.')\n            );\n        }\n\n        $form = new UserPassphrasePoliciesSettingsForm();\n        if (!$form->execute($requestData)) {\n            throw new FormValidationException(\n                __('Could not validate the user passphrase policies settings.'),\n                $form\n            );\n        }\n\n        /** @var \\Passbolt\\UserPassphrasePolicies\\Model\\Dto\\UserPassphrasePoliciesSettingsDto $settingsDto */\n        $settingsDto = UserPassphrasePoliciesSettingsDto::createFromArray($form->getData());\n\n        /** @var \\Passbolt\\UserPassphrasePolicies\\Model\\Table\\UserPassphrasePoliciesSettingsTable $userPassphrasePoliciesSettingsTable */\n        $userPassphrasePoliciesSettingsTable = $this->fetchTable('Passbolt/UserPassphrasePolicies.UserPassphrasePoliciesSettings'); // phpcs:ignore\n\n        /** @var \\Passbolt\\UserPassphrasePolicies\\Model\\Entity\\UserPassphrasePoliciesSetting $userPassphrasePoliciesSetting */\n        $userPassphrasePoliciesSetting = $userPassphrasePoliciesSettingsTable->createOrUpdateSetting(\n            $userPassphrasePoliciesSettingsTable->getProperty(),\n            $settingsDto->toOrganizationSettingValueArray(),\n            $uac\n        );\n","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/plugins/PassboltEe/UserPassphrasePolicies/src/Service/UserPassphrasePoliciesSetSettingsService.php#L40-L76","documentation":"After the admin check, UserPassphrasePoliciesSetSettingsService::createOrUpdate runs the request data through UserPassphrasePoliciesSettingsForm. If execute() fails, it throws FormValidationException with this message and the form object, which carries the per-field validation errors.","triggerScenarios":"POSTing user passphrase policies settings whose payload fails form rules - e.g. invalid 'source' value, non-numeric or out-of-range length, bad entropy/weak-min-entropy values, or wrong value types.","commonSituations":"Client sends snake_case vs camelCase mismatch, omits required fields, or sends strings where integers are expected; automation posts raw config that was never validated.","solutions":["Read the errors from the FormValidationException/form to identify the offending fields.","Correct the payload to match UserPassphrasePoliciesSettingsForm's schema (valid source, integer lengths within range) and resend.","Validate the DTO client-side (e.g. via UserPassphrasePoliciesSettingsDto shapes) before posting."],"exampleFix":"// before\n{ \"source\": \"policy\", \"length_min\": \"eight\" }\n// after\n{ \"source\": \"policy\", \"length_min\": 8 }","handlingStrategy":"validation","validationCode":"const valid = Number.isInteger(cfg.length_min) && cfg.length_min >= 8 && ['policy','user'].includes(cfg.source); if (!valid) return reject('invalid passphrase policy payload');","typeGuard":"const isValidPolicyPayload = (p): p is PolicyPayload => typeof p?.length_min === 'number' && typeof p?.source === 'string';","tryCatchPattern":"try { await postSettings(payload); } catch (e) { if (e.formErrors) showFieldErrors(e.formErrors); }","preventionTips":["Mirror the form schema client-side and validate before POST.","Send integer types, not strings, for numeric fields.","Capture and display the form errors attached to FormValidationException."],"tags":["user-passphrase-policies","settings","validation"],"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"}