langflow-ai/langflow · warning · HTTPException

Flow version '{flow_version.id}' cannot be used as a deploym

Error message

Flow version '{flow_version.id}' cannot be used as a deployment artifact: {exc.errors()[0]['msg']}

What it means

422 from the base deployment mapper when BaseFlowArtifact construction raises pydantic ValidationError — the flow version's data does not satisfy the artifact schema (e.g. data is not valid flow JSON, required fields wrong types). The first validation error message is surfaced (exc.errors()[0]['msg']) prefixed by the version id, so the caller sees exactly which constraint failed.

Source

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

        flow_name = getattr(flow_row, "name", None) or ""
        if not flow_name:
            raise HTTPException(
                status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
                detail=(
                    f"Cannot build deployment artifact: the parent flow for version "
                    f"'{flow_version.id}' has been deleted or has no name."
                ),
            )
        try:
            return BaseFlowArtifact(
                id=flow_version.flow_id,
                name=flow_name,
                description=getattr(flow_row, "description", None),
                data=flow_version.data,
            )
        except ValidationError as exc:
            raise HTTPException(
                status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
                detail=(
                    f"Flow version '{flow_version.id}' cannot be used as a deployment "
                    f"artifact: {exc.errors()[0]['msg']}"
                ),
            ) from exc

    async def resolve_deployment_list_adapter_params(
        self,
        *,
        deployment_type: DeploymentType | None,
        provider_params: dict[str, Any] | None,
    ) -> DeploymentListParams | None:
        if deployment_type is None and provider_params is None:
            return None
        return DeploymentListParams(
            deployment_types=[deployment_type] if deployment_type is not None else None,
            provider_params=provider_params,

View on GitHub (pinned to 976ec789d2)

Solutions

  1. Read the surfaced validation msg — it names the failing field/constraint
  2. Open the flow in the editor and re-save to rewrite clean version data, then re-deploy
  3. If version data is unrecoverable, create a new version from the current flow state
Defensive patterns

Strategy: try-catch

Validate before calling

from langflow.api.v1.mappers.deployments.base import BaseFlowArtifact
BaseFlowArtifact.model_validate({"id": fv["flow_id"], "name": name, "data": fv["data"]})  # dry-run locally

Try / catch

try:
    await create_deployment(client, version_id)
except httpx.HTTPStatusError as e:
    if e.response.status_code == 422 and "cannot be used as a deployment artifact" in e.response.json()["detail"]:
        version = await resave_flow_new_version(client, flow_id)  # rewrite clean data
        await create_deployment(client, version.id)
    else:
        raise

Prevention

When it happens

Trigger: Deploying a flow version whose stored `data` is null, malformed, or schema-incompatible — corrupted saves, versions written by an older/newer Langflow with a different artifact schema, or hand-edited DB rows.

Common situations: Upgrading Langflow changes BaseFlowArtifact validation rules and old versions no longer parse; flow JSON truncated during a failed save; importing a flow from another instance.

Related errors


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