{"record":{"id":"35fb493b1e0067e1","repo":"passbolt/passbolt_api","slug":"invalid-request-please-provide-the-required-data-35fb49","errorCode":null,"errorMessage":"Invalid request. Please provide the required data.","messagePattern":"Invalid request\\. Please provide the required data\\.","errorType":"http","errorClass":"BadRequestException","httpStatus":400,"severity":"error","filePath":"plugins/PassboltEe/AccountRecovery/src/Controller/AccountRecoveryResponses/AccountRecoveryResponsesCreateController.php","lineNumber":48,"sourceCode":"{\n    /**\n     * Creates an account recovery response\n     * Sends an email to the requesting user and the admins on success\n     *\n     * @param \\Passbolt\\Rbacs\\Service\\ActionAccessControl\\RoleActionAccessControlServiceInterface $accessControlService service assessing if the user's role has access to this action\n     * @return void\n     * @throws \\Cake\\Http\\Exception\\BadRequestException if the data provided is not valid\n     */\n    public function post(RoleActionAccessControlServiceInterface $accessControlService): void\n    {\n        $accessControlService->controlUserRoleActionAccess(\n            $this->User->getRoleEntity(),\n            UserAction::getInstance()->getActionId()\n        );\n\n        $data = $this->getRequest()->getData();\n        if (!isset($data) || !is_array($data) || empty($data)) {\n            throw new BadRequestException(__('Invalid request. Please provide the required data.'));\n        }\n\n        $response = (new AccountRecoveryResponsesCreateService())->create($this->User->getAccessControl(), $data);\n\n        $this->success(__('The operation was successful.'), $response);\n    }\n}\n","sourceCodeStart":30,"sourceCodeEnd":56,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/plugins/PassboltEe/AccountRecovery/src/Controller/AccountRecoveryResponses/AccountRecoveryResponsesCreateController.php#L30-L56","documentation":"Thrown by the account recovery response creation endpoint when the request body is null, not an array, or empty. The endpoint requires the response payload (with the encrypted response data and security token) before invoking the create service.","triggerScenarios":"POST /account-recovery/responses with no JSON body, an empty object {}, or a body sent with the wrong Content-Type so CakePHP parses no data.","commonSituations":"Client forgot to JSON.stringify the payload; missing Content-Type: application/json header; middleware or proxy stripping the body; older client versions posting a different schema.","solutions":["Send a JSON body with Content-Type: application/json containing the account_recovery_private_key_responses data.","Verify the client actually serializes the payload (not undefined).","Check proxies/gateways are not dropping the request body.","Confirm the client version matches the current API schema for responses."],"exampleFix":"// before\nfetch('/account-recovery/responses', {method:'POST', headers:{'Content-Type':'text/plain'}, body: JSON.stringify(data)});\n// after\nfetch('/account-recovery/responses', {method:'POST', headers:{'Content-Type':'application/json'}, body: JSON.stringify(data)});","handlingStrategy":"validation","validationCode":"if (!payload || typeof payload !== 'object' || Object.keys(payload).length === 0) throw new Error('response payload required');","typeGuard":"function hasBody(v) { return v !== null && typeof v === 'object' && !Array.isArray(v) && Object.keys(v).length > 0; }","tryCatchPattern":"try { await api.createAccountRecoveryResponse(payload); } catch (e) { if (e.code === 400 && /provide the required data/.test(e.message)) { /* rebuild payload and resend */ } else { throw e; } }","preventionTips":["Always send JSON with Content-Type: application/json.","Assert the serialized body is non-empty before fetch.","Bypass body-stripping proxies or verify their config.","Keep client schema in sync with the server API."],"tags":["validation","bad-request","request-body","account-recovery"],"backgroundTag":"empty-required-field","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"}