langflow-ai/langflow · error · ValueError

provider_data.existing_agent_id cannot be set to null.

Error message

provider_data.existing_agent_id cannot be set to null.

What it means

Model validator on WatsonxApiDeploymentCreatePayload: existing_agent_id (used to track an already-existing wxO agent in Langflow instead of creating one) may be omitted, but if the key is present it must not be null. Sending "existing_agent_id": null raises ValueError and a 422 on deployment create.

Source

Thrown at src/backend/base/langflow/api/v1/mappers/deployments/watsonx_orchestrate/payloads.py:373

        ),
    )
    connections: list[WatsonxApiKeyValueConnectionPayload] = Field(default_factory=list)
    add_flows: list[WatsonxApiAddFlowItem] = Field(default_factory=list)
    upsert_tools: list[WatsonxApiCreateUpsertToolItem] = Field(default_factory=list)
    existing_agent_id: NormalizedStr | None = Field(
        default=None,
        description=(
            "Provider-owned agent id to track in Langflow instead of creating a new wxO agent. "
            "When provided, the request must not include fields that would update the wxO agent."
        ),
    )

    @model_validator(mode="after")
    def validate_create_operation_requirements(self) -> WatsonxApiDeploymentCreatePayload:
        if "existing_agent_id" in self.model_fields_set:
            if self.existing_agent_id is None:
                msg = "provider_data.existing_agent_id cannot be set to null."
                raise ValueError(msg)
            if len(self.model_fields_set) > 1:
                msg = (
                    "existing_agent_id is only for tracking existing wxO agents in Langflow and cannot include "
                    "fields that update the wxO agent. Update the deployment after it is tracked."
                )
                raise ValueError(msg)
            return self
        if self.display_name is None:
            msg = "provider_data.display_name is required for new agent creation."
            raise ValueError(msg)
        if self.llm is None:
            msg = "provider_data.llm is required for new agent creation."
            raise ValueError(msg)
        # TODO: Allow wxO agent creation without initial flows/tools once the adapter create path supports it.
        if not (self.add_flows or self.upsert_tools):
            msg = "provider_data must include at least one add_flows or upsert_tools item for new agent creation."
            raise ValueError(msg)
        _validate_api_unique_connection_app_ids(connections=self.connections)

View on GitHub (pinned to 976ec789d2)

Solutions

  1. Remove the existing_agent_id key from provider_data when creating a new agent.
  2. If you meant to track an existing agent, supply the real wxO agent id string.
  3. Serialize client state with exclude_none / drop-null-keys semantics.

Example fix

// before
{"provider_data": {"existing_agent_id": null, "display_name": "A", ...}}
// after
{"provider_data": {"display_name": "A", ...}}
Defensive patterns

Strategy: type-guard

Validate before calling

if provider_data.get("existing_agent_id", "NOT_SET") is None:
    del provider_data["existing_agent_id"]  # omit instead of null

Type guard

const existingAgentIdValid = (pd: Record<string, unknown>): boolean =>
  !("existing_agent_id" in pd) || typeof pd.existing_agent_id === "string";

Prevention

When it happens

Trigger: POST /deployments with provider_data.existing_agent_id explicitly set to JSON null.

Common situations: Client code that always includes the key and sets it to null when not tracking an existing agent; form state initialized to None and serialized verbatim; OpenAPI-generated clients materializing optional fields as null.

Related errors


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