{"record":{"id":"7acd9418d46374f2","repo":"passbolt/passbolt_api","slug":"the-account-request-is-invalid","errorCode":null,"errorMessage":"The account request is invalid.","messagePattern":"The account request is invalid\\.","errorType":"validation","errorClass":"ValidationException","httpStatus":422,"severity":"error","filePath":"plugins/PassboltEe/AccountRecovery/src/Model/Table/AccountRecoveryRequestsTable.php","lineNumber":458,"sourceCode":"     * @return \\Passbolt\\AccountRecovery\\Model\\Entity\\AccountRecoveryRequest\n     */\n    public function updateStatusAndValidateEntity(\n        UserAccessControl $uac,\n        AccountRecoveryRequest $requestEntity,\n        string $responseStatus\n    ): AccountRecoveryRequest {\n        /** @var \\Passbolt\\AccountRecovery\\Model\\Entity\\AccountRecoveryRequest $requestEntity */\n        $requestEntity = $this->patchEntity($requestEntity, [\n            'status' => $this->getRequestStatusFromResponse($responseStatus),\n            'modified_by' => $uac->getId(),\n        ], ['accessibleFields' => [\n            'status' => true,\n            'modified_by' => true,\n        ]]);\n\n        if ($requestEntity->getErrors()) {\n            $msg = __('The account request is invalid.');\n            throw new ValidationException($msg, $requestEntity, $this);\n        }\n\n        return $requestEntity;\n    }\n\n    /**\n     * Return new request status based on response status\n     *\n     * @param string $status response status\n     * @return string mapped request status\n     */\n    protected function getRequestStatusFromResponse(string $status): string\n    {\n        if ($status === AccountRecoveryResponse::STATUS_REJECTED) {\n            return AccountRecoveryRequest::ACCOUNT_RECOVERY_REQUEST_REJECTED;\n        }\n        if ($status === AccountRecoveryResponse::STATUS_APPROVED) {\n            return AccountRecoveryRequest::ACCOUNT_RECOVERY_REQUEST_APPROVED;","sourceCodeStart":440,"sourceCodeEnd":476,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/plugins/PassboltEe/AccountRecovery/src/Model/Table/AccountRecoveryRequestsTable.php#L440-L476","documentation":"Thrown by AccountRecoveryRequestsTable::updateStatusAndValidateEntity when the account recovery request entity fails CakePHP entity validation after being patched with a new status and modified_by. It signals that the submitted status transition (e.g. approving/rejecting a recovery request by an administrator) violates the table's validation rules. The entity with its errors is attached to the exception.","triggerScenarios":"Calling the account recovery request status-update service (POST /account-recovery/requests/<id>.json for admins) with a status value not in the allowed list, an unknown request id producing rule violations, or patching an entity that already has errors from a prior state check.","commonSituations":"Admin UI or API client sends a typo'd status string (e.g. 'approve' instead of 'approved'); attempting to update a request that is already in a terminal state; automated scripts replaying stale requests after the organization policy changed.","solutions":["Check the errors array on the exception entity to see which field failed validation","Send only the exact allowed status values 'approved' or 'rejected' in the request payload","Verify the request id exists and has not already been approved/rejected","Ensure the account recovery organization policy is enabled before attempting status updates"],"exampleFix":"// before\nPATCH /account-recovery/requests/<uuid> {\"status\": \"approve\"}\n// after\nPATCH /account-recovery/requests/<uuid> {\"status\": \"approved\"}","handlingStrategy":"validation","validationCode":"const ALLOWED = ['approved', 'rejected'];\nif (!ALLOWED.includes(payload.status)) {\n  throw new Error(`status must be one of ${ALLOWED.join(', ')}`);\n}","typeGuard":"function isValidRequestStatus(s) {\n  return typeof s === 'string' && ['approved', 'rejected'].includes(s);\n}","tryCatchPattern":"try {\n  await api.updateRequestStatus(id, status);\n} catch (e) {\n  if (e.body?.errors) console.error(e.body.errors); // inspect field errors\n}","preventionTips":["Always send the exact lowercase enum values 'approved'/'rejected'","Check the request is still pending before updating","Keep payloads minimal: only status field, let server set modified_by"],"tags":["validation","account-recovery","status-update"],"backgroundTag":"invalid-enum-value","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"}