{"record":{"id":"7561c4f27ed314ca","repo":"passbolt/passbolt_api","slug":"could-not-validate-the-sso-recover-request","errorCode":null,"errorMessage":"Could not validate the SSO recover request.","messagePattern":"Could not validate the SSO recover request\\.","errorType":"validation","errorClass":"FormValidationException","httpStatus":null,"severity":"warning","filePath":"plugins/PassboltEe/SsoRecover/src/Controller/RecoverStartController.php","lineNumber":67,"sourceCode":"     */\n    public function start(): void\n    {\n        if (!$this->request->is('json')) {\n            throw new BadRequestException(__('This is not a valid Ajax/Json request.'));\n        }\n\n        $this->User->assertNotLoggedIn();\n\n        // Make sure SSO settings are set.\n        try {\n            $settingsDto = (new SsoSettingsGetService())->getActiveOrFail();\n        } catch (RecordNotFoundException $e) {\n            throw new BadRequestException(__('No valid SSO settings found.'), null, $e);\n        }\n\n        $form = new SsoRecoverStartForm();\n        if (!$form->execute($this->getRequest()->getData())) {\n            throw new FormValidationException(__('Could not validate the SSO recover request.'), $form);\n        }\n\n        // Assert & consume sso auth token\n        $ssoAuthService = new SsoAuthenticationTokenGetService();\n        try {\n            $ssoAuthToken = $ssoAuthService->getOrFail(\n                $form->getData('token'),\n                SsoState::TYPE_SSO_RECOVER\n            );\n        } catch (RecordNotFoundException $e) {\n            throw new BadRequestException($e->getMessage(), null, $e);\n        }\n\n        $uac = new ExtendedUserAccessControl(\n            Role::GUEST,\n            $ssoAuthToken->user_id,\n            null,\n            $this->User->ip(),","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/plugins/PassboltEe/SsoRecover/src/Controller/RecoverStartController.php#L49-L85","documentation":"Thrown when SsoRecoverStartForm::execute() fails validation of the posted data (typically the username/email field). A FormValidationException is raised with this generic message; the detailed field errors are attached to the form object and returned in the error response body.","triggerScenarios":"POST /sso/recover/start with missing username, an email not matching validation rules, or extra malformed fields; empty request body.","commonSituations":"API client omits the username field or sends it under the wrong key; email contains whitespace or invalid format; client sends form-encoded data where field names don't match the form schema.","solutions":["Inspect the error response body for per-field validation details","Send {\"username\": \"<valid-email>\"} in the JSON body","Trim whitespace and validate the email client-side before calling","Align request field names with SsoRecoverStartForm's schema"],"exampleFix":"// before\n{\"user\": \"alice@example.com\"}   // wrong field name\n// after\n{\"username\": \"alice@example.com\"}","handlingStrategy":"validation","validationCode":"const emailRe = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/;\nif (typeof username !== 'string' || !emailRe.test(username.trim())) {\n  throw new Error('username must be a valid email address');\n}","typeGuard":"const isValidUsername = (v) => typeof v === 'string' && /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(v.trim());","tryCatchPattern":"try {\n  await ssoRecoverStart({username});\n} catch (e) {\n  if (e.message.includes('Could not validate')) console.warn(e.formErrors ?? 'Check username field');\n  else throw e;\n}","preventionTips":["Validate email format client-side before submitting","Send the field under the exact key the form expects (username)","Trim whitespace from user input","Read the per-field errors returned in the response body"],"tags":["sso","form-validation","validation","bad-request"],"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"}