{"record":{"id":"1818f2d8ad832be8","repo":"Significant-Gravitas/AutoGPT","slug":"source-and-target-organizations-must-be-different","errorCode":null,"errorMessage":"Source and target organizations must be different","messagePattern":"Source and target organizations must be different","errorType":"validation","errorClass":"ValueError","httpStatus":400,"severity":"warning","filePath":"autogpt_platform/backend/backend/api/features/transfers/db.py","lineNumber":39,"sourceCode":"    user_id: str,\n    reason: str | None = None,\n) -> TransferResponse:\n    \"\"\"Create a new transfer request from source org to target org.\n\n    Validates:\n    - resource_type is one of the allowed types\n    - source and target orgs are different\n    - target org exists\n    - the resource exists and belongs to the source org\n    \"\"\"\n    if resource_type not in _VALID_RESOURCE_TYPES:\n        raise ValueError(\n            f\"Invalid resource_type '{resource_type}'. \"\n            f\"Must be one of: {', '.join(sorted(_VALID_RESOURCE_TYPES))}\"\n        )\n\n    if source_org_id == target_org_id:\n        raise ValueError(\"Source and target organizations must be different\")\n\n    target_org = await prisma.organization.find_unique(where={\"id\": target_org_id})\n    if target_org is None or target_org.deletedAt is not None:\n        raise NotFoundError(f\"Target organization {target_org_id} not found\")\n\n    await _validate_resource_ownership(resource_type, resource_id, source_org_id)\n\n    tr = await prisma.transferrequest.create(\n        data={\n            \"resourceType\": resource_type,\n            \"resourceId\": resource_id,\n            \"sourceOrganizationId\": source_org_id,\n            \"targetOrganizationId\": target_org_id,\n            \"initiatedByUserId\": user_id,\n            \"status\": \"PENDING\",\n            \"reason\": reason,\n        }\n    )","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/Significant-Gravitas/AutoGPT/blob/9c8bb5550f446ba5d3046b78896578742495b3cf/autogpt_platform/backend/backend/api/features/transfers/db.py#L21-L57","documentation":"ValueError from create_transfer_request() when source_org_id == target_org_id. Transferring a resource to the organization that already owns it is rejected as a no-op before any DB lookup; it is a 400-class client error.","triggerScenarios":"Transfer form submitted with the same organization selected in both source and target pickers, or client code defaulting both IDs to the user's current active org.","commonSituations":"UI dropdown bug defaulting target to the active org; users re-submitting a form after switching org context so both fields capture the same ID.","solutions":["Select a different target organization and resubmit.","Fix the client form: exclude the source org from the target picker and validate inequality before submit.","If you are testing, use two distinct seeded org IDs."],"exampleFix":"// before\nif (sourceOrgId && targetOrgId) submitTransfer(sourceOrgId, targetOrgId);\n\n// after\nif (sourceOrgId && targetOrgId && sourceOrgId !== targetOrgId) {\n  submitTransfer(sourceOrgId, targetOrgId);\n}","handlingStrategy":"validation","validationCode":"def is_distinct_transfer(source_org_id: str, target_org_id: str) -> bool:\n    return bool(source_org_id) and bool(target_org_id) and source_org_id != target_org_id","typeGuard":null,"tryCatchPattern":"try:\n    resp = await create_transfer_request(...)\nexcept ValueError as e:\n    if \"must be different\" in str(e):\n        show_form_error(\"Choose a different target organization\")\n        return\n    raise","preventionTips":["Exclude the source org from the target-organization picker in the UI.","Validate inequality client-side before enabling submit."],"tags":["transfers","validation","organizations"],"backgroundTag":null,"analyzedSha":"9c8bb5550f446ba5d3046b78896578742495b3cf","analyzedAt":"2026-08-14T17:17:21.957Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}