{"record":{"id":"ce1d265581d25675","repo":"Significant-Gravitas/AutoGPT","slug":"cannot-approve-a-transfer-with-status-tr-status","errorCode":null,"errorMessage":"Cannot approve a transfer with status '{tr.status}'","messagePattern":"Cannot approve a transfer with status '(.+?)'","errorType":"validation","errorClass":"ValueError","httpStatus":400,"severity":"error","filePath":"autogpt_platform/backend/backend/api/features/transfers/db.py","lineNumber":91,"sourceCode":"\n\nasync def approve_transfer(\n    transfer_id: str,\n    user_id: str,\n    org_id: str,\n) -> TransferResponse:\n    \"\"\"Approve a transfer from the source or target side.\n\n    - If user's active org is the source org, sets sourceApprovedByUserId.\n    - If user's active org is the target org, sets targetApprovedByUserId.\n    - Advances the status accordingly.\n    \"\"\"\n    tr = await prisma.transferrequest.find_unique(where={\"id\": transfer_id})\n    if tr is None:\n        raise NotFoundError(f\"Transfer request {transfer_id} not found\")\n\n    if tr.status in (\"COMPLETED\", \"REJECTED\"):\n        raise ValueError(f\"Cannot approve a transfer with status '{tr.status}'\")\n\n    update_data: dict = {}\n\n    if org_id == tr.sourceOrganizationId:\n        if tr.sourceApprovedByUserId is not None:\n            raise ValueError(\"Source organization has already approved this transfer\")\n        update_data[\"sourceApprovedByUserId\"] = user_id\n        if tr.targetApprovedByUserId is not None:\n            # Both sides approved — ready for execution (NOT completed yet)\n            update_data[\"status\"] = \"TARGET_APPROVED\"\n        else:\n            update_data[\"status\"] = \"SOURCE_APPROVED\"\n\n    elif org_id == tr.targetOrganizationId:\n        if tr.targetApprovedByUserId is not None:\n            raise ValueError(\"Target organization has already approved this transfer\")\n        update_data[\"targetApprovedByUserId\"] = user_id\n        if tr.sourceApprovedByUserId is not None:","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/Significant-Gravitas/AutoGPT/blob/9c8bb5550f446ba5d3046b78896578742495b3cf/autogpt_platform/backend/backend/api/features/transfers/db.py#L73-L109","documentation":"Error \"Cannot approve a transfer with status '{tr.status}'\" thrown in Significant-Gravitas/AutoGPT.","triggerScenarios":"Thrown at autogpt_platform/backend/backend/api/features/transfers/db.py:91 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the transfer status; only pending transfers can be approved.","Refresh the transfer details before approving."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"9c8bb5550f446ba5d3046b78896578742495b3cf","analyzedAt":"2026-08-14T17:17:21.957Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}