{"record":{"id":"4aa9b10a7356e076","repo":"langflow-ai/langflow","slug":"provider-data-existing-agent-id-cannot-be-set-to-n","errorCode":null,"errorMessage":"provider_data.existing_agent_id cannot be set to null.","messagePattern":"provider_data\\.existing_agent_id cannot be set to null\\.","errorType":"validation","errorClass":"ValueError","httpStatus":422,"severity":"error","filePath":"src/backend/base/langflow/api/v1/mappers/deployments/watsonx_orchestrate/payloads.py","lineNumber":373,"sourceCode":"        ),\n    )\n    connections: list[WatsonxApiKeyValueConnectionPayload] = Field(default_factory=list)\n    add_flows: list[WatsonxApiAddFlowItem] = Field(default_factory=list)\n    upsert_tools: list[WatsonxApiCreateUpsertToolItem] = Field(default_factory=list)\n    existing_agent_id: NormalizedStr | None = Field(\n        default=None,\n        description=(\n            \"Provider-owned agent id to track in Langflow instead of creating a new wxO agent. \"\n            \"When provided, the request must not include fields that would update the wxO agent.\"\n        ),\n    )\n\n    @model_validator(mode=\"after\")\n    def validate_create_operation_requirements(self) -> WatsonxApiDeploymentCreatePayload:\n        if \"existing_agent_id\" in self.model_fields_set:\n            if self.existing_agent_id is None:\n                msg = \"provider_data.existing_agent_id cannot be set to null.\"\n                raise ValueError(msg)\n            if len(self.model_fields_set) > 1:\n                msg = (\n                    \"existing_agent_id is only for tracking existing wxO agents in Langflow and cannot include \"\n                    \"fields that update the wxO agent. Update the deployment after it is tracked.\"\n                )\n                raise ValueError(msg)\n            return self\n        if self.display_name is None:\n            msg = \"provider_data.display_name is required for new agent creation.\"\n            raise ValueError(msg)\n        if self.llm is None:\n            msg = \"provider_data.llm is required for new agent creation.\"\n            raise ValueError(msg)\n        # TODO: Allow wxO agent creation without initial flows/tools once the adapter create path supports it.\n        if not (self.add_flows or self.upsert_tools):\n            msg = \"provider_data must include at least one add_flows or upsert_tools item for new agent creation.\"\n            raise ValueError(msg)\n        _validate_api_unique_connection_app_ids(connections=self.connections)","sourceCodeStart":355,"sourceCodeEnd":391,"githubUrl":"https://github.com/langflow-ai/langflow/blob/976ec789d2886a86de109c044d089d68e96c9a35/src/backend/base/langflow/api/v1/mappers/deployments/watsonx_orchestrate/payloads.py#L355-L391","documentation":"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.","triggerScenarios":"POST /deployments with provider_data.existing_agent_id explicitly set to JSON null.","commonSituations":"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.","solutions":["Remove the existing_agent_id key from provider_data when creating a new agent.","If you meant to track an existing agent, supply the real wxO agent id string.","Serialize client state with exclude_none / drop-null-keys semantics."],"exampleFix":"// before\n{\"provider_data\": {\"existing_agent_id\": null, \"display_name\": \"A\", ...}}\n// after\n{\"provider_data\": {\"display_name\": \"A\", ...}}","handlingStrategy":"type-guard","validationCode":"if provider_data.get(\"existing_agent_id\", \"NOT_SET\") is None:\n    del provider_data[\"existing_agent_id\"]  # omit instead of null","typeGuard":"const existingAgentIdValid = (pd: Record<string, unknown>): boolean =>\n  !(\"existing_agent_id\" in pd) || typeof pd.existing_agent_id === \"string\";","tryCatchPattern":null,"preventionTips":["Only include existing_agent_id when actually tracking an agent.","Drop null keys at serialization time.","Model 'track existing' and 'create new' as separate client-side payload builders."],"tags":["watsonx-orchestrate","pydantic","validation","http-422","null-handling","existing-agent"],"backgroundTag":null,"analyzedSha":"976ec789d2886a86de109c044d089d68e96c9a35","analyzedAt":"2026-08-14T18:23:12.227Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}