langflow-ai/langflow · error · HTTPException

Provider account is already tracked by user.

Error message

Provider account is already tracked by user.

What it means

Raised as HTTP 409 by _raise_http_for_provider_account_value_error when creating/updating a deployment provider account would duplicate an existing record: the underlying ValueError message contains 'already exists' or 'conflicts with an existing record'. It is a deliberate translation of a service-layer uniqueness check into a RESTful conflict response with a stable, client-displayable message.

Source

Thrown at src/backend/base/langflow/api/v1/deployments.py:216

        ),
    ),
]


def _field_was_explicitly_set(model: object, field_name: str) -> bool:
    """Return True when a Pydantic-style model explicitly received *field_name*.

    Falls back to False for mocks and non-Pydantic objects so route handler unit
    tests that use ``MagicMock`` payloads keep their previous behavior.
    """
    fields_set = getattr(model, "model_fields_set", None)
    return isinstance(fields_set, set) and field_name in fields_set


def _raise_http_for_provider_account_value_error(exc: ValueError) -> None:
    message = str(exc).lower()
    if "already exists" in message or "conflicts with an existing record" in message:
        raise HTTPException(
            status_code=status.HTTP_409_CONFLICT,
            detail="Provider account is already tracked by user.",
        ) from exc
    raise_http_for_value_error(exc)


async def _count_provider_deployments_after_reconciliation(
    *,
    session: DbSession,
    provider_account,
    user_id: UUID,
) -> int:
    """Return remaining deployments after best-effort stale-row reconciliation."""
    deployment_count = await count_deployments_by_provider(
        session,
        user_id=user_id,
        deployment_provider_account_id=provider_account.id,
    )

View on GitHub (pinned to 976ec789d2)

Solutions

  1. List existing provider accounts (GET /deployments/providers) — the account is likely already there; use it instead of re-creating.
  2. If you want a fresh link, delete the existing account first, then re-create.
  3. Guard the create button/form against double submission (disable on in-flight).
  4. On 409, treat the existing record as the outcome rather than surfacing an error to the user.

Example fix

# before
res = await client.post("/api/v1/deployments/providers", json=payload)
res.raise_for_status()  # 409 explodes

# after
if res.status_code == 409:
    accounts = (await client.get("/api/v1/deployments/providers")).json()
    account = next(a for a in accounts if a["provider_type"] == payload["provider_type"])
else:
    res.raise_for_status()
Defensive patterns

Strategy: try-catch

Validate before calling

# Check for an existing provider account before creating
accounts = (await client.get("/api/v1/deployments/providers")).json()
if any(a["provider_type"] == payload["provider_type"] and a["identifier"] == payload["identifier"] for a in accounts):
    return  # already tracked; reuse it

Try / catch

try:
    res = await client.post("/api/v1/deployments/providers", json=payload)
except httpx.HTTPStatusError as e:
    if e.response.status_code == 409:
        return await get_existing_provider_account(payload)  # idempotent outcome
    raise

Prevention

When it happens

Trigger: POST /api/v1/deployments/providers (or PUT on a provider account) with a (provider_type, identifier) combination the same user has already registered — e.g. adding the same GitHub/OAuth/app-provider account twice.

Common situations: Double-submitting the 'add provider account' form; retrying a timed-out create that actually succeeded; re-connecting an OAuth integration that is already linked; UI not refreshing the account list.

Related errors


AI-assisted analysis of langflow-ai/langflow@976ec789d2 (2026-08-14). Data as JSON: /api/errors/082073796195bcd0. Report an issue: GitHub.