Significant-Gravitas/AutoGPT · error · NotFoundError

Target organization {target_org_id} not found

Error message

Target organization {target_org_id} not found

What it means

NotFoundError from create_transfer_request() when prisma.organization.find_unique(target_org_id) returns None OR the row's deletedAt is set — the platform soft-deletes organizations, so a tombstoned org is treated as nonexistent even though its row remains.

Source

Thrown at autogpt_platform/backend/backend/api/features/transfers/db.py:43

    Validates:
    - resource_type is one of the allowed types
    - source and target orgs are different
    - target org exists
    - the resource exists and belongs to the source org
    """
    if resource_type not in _VALID_RESOURCE_TYPES:
        raise ValueError(
            f"Invalid resource_type '{resource_type}'. "
            f"Must be one of: {', '.join(sorted(_VALID_RESOURCE_TYPES))}"
        )

    if source_org_id == target_org_id:
        raise ValueError("Source and target organizations must be different")

    target_org = await prisma.organization.find_unique(where={"id": target_org_id})
    if target_org is None or target_org.deletedAt is not None:
        raise NotFoundError(f"Target organization {target_org_id} not found")

    await _validate_resource_ownership(resource_type, resource_id, source_org_id)

    tr = await prisma.transferrequest.create(
        data={
            "resourceType": resource_type,
            "resourceId": resource_id,
            "sourceOrganizationId": source_org_id,
            "targetOrganizationId": target_org_id,
            "initiatedByUserId": user_id,
            "status": "PENDING",
            "reason": reason,
        }
    )
    return TransferResponse.from_db(tr)


async def list_transfers(org_id: str) -> list[TransferResponse]:

View on GitHub (pinned to 9c8bb5550f)

Solutions

  1. Refresh the organizations list and pick a currently active org.
  2. Verify the org row: `SELECT id, "deletedAt" FROM "Organization" WHERE id = '<uuid>'` — if deletedAt is set the org is gone.
  3. If it must be restored, un-delete via admin tooling before retrying the transfer.
Defensive patterns

Strategy: validation

Validate before calling

org = await prisma.organization.find_unique(where={"id": target_org_id})
target_org_active = org is not None and org.deletedAt is None

Try / catch

try:
    resp = await create_transfer_request(...)
except NotFoundError as e:
    if "Target organization" in str(e):
        refresh_org_picker()  # drop deleted orgs
        return
    raise

Prevention

When it happens

Trigger: Transfer request targeting an org ID that was never created, was hard-missing in this environment, or was soft-deleted (deletedAt non-null) after the user's org picker cached it.

Common situations: Stale org list in the client after an org was dissolved; environment mismatch where the org exists in staging but not prod; typo'd org UUID.

Related errors


AI-assisted analysis of Significant-Gravitas/AutoGPT@9c8bb5550f (2026-08-14). Data as JSON: /api/errors/68a7cc5765eccc39. Report an issue: GitHub.