{"record":{"id":"fca78041f5b2e871","repo":"langflow-ai/langflow","slug":"flow-version-id-must-be-provided-as-a-uuid-string","errorCode":null,"errorMessage":"flow_version_id must be provided as a UUID string or UUID object.","messagePattern":"flow_version_id must be provided as a UUID string or UUID object\\.","errorType":"validation","errorClass":"ValueError","httpStatus":422,"severity":"error","filePath":"src/backend/base/langflow/api/v1/mappers/deployments/watsonx_orchestrate/payloads.py","lineNumber":420,"sourceCode":"        raise ValueError(msg)\n\n\nclass WatsonxApiCreatedTool(BaseModel):\n    \"\"\"API response shape for a tool created from a Langflow flow version.\"\"\"\n\n    model_config = {\"extra\": \"forbid\"}\n\n    flow_version_id: UUID\n    tool_id: NonEmptyString = Field(description=\"Provider-owned tool identifier.\")\n\n    @field_validator(\"flow_version_id\", mode=\"before\")\n    @classmethod\n    def normalize_flow_version_id(cls, value: Any) -> UUID:\n        if isinstance(value, UUID):\n            return value\n        if not isinstance(value, str):\n            msg = \"flow_version_id must be provided as a UUID string or UUID object.\"\n            raise ValueError(msg)  # noqa: TRY004\n        try:\n            return UUID(value)\n        except ValueError as exc:\n            msg = \"flow_version_id must be a valid UUID.\"\n            raise ValueError(msg) from exc\n\n\nclass WatsonxApiDeploymentCreateResultData(BaseModel):\n    \"\"\"Provider-result payload used by Watsonx mapper create shapers.\"\"\"\n\n    model_config = {\"extra\": \"ignore\"}\n\n    name: NonEmptyString = Field(description=\"Provider technical agent name.\")\n    display_name: NonEmptyString\n    created_app_ids: list[NonEmptyString] = Field(default_factory=list)\n    created_tools: list[WatsonxApiCreatedTool] = Field(default_factory=list)\n\n    @classmethod","sourceCodeStart":402,"sourceCodeEnd":438,"githubUrl":"https://github.com/langflow-ai/langflow/blob/976ec789d2886a86de109c044d089d68e96c9a35/src/backend/base/langflow/api/v1/mappers/deployments/watsonx_orchestrate/payloads.py#L402-L438","documentation":"Pydantic field validator (mode='before') on WatsonxApiCreatedTool.flow_version_id rejects values that are neither a UUID instance nor a string. The Watsonx Orchestrate deployment mapper requires the Langflow flow version id as a UUID, and any non-string type (int, None, dict, list) fails before Pydantic's own UUID coercion runs. The error surfaces as a pydantic ValidationError wrapped in the mapper's payload-shaping response.","triggerScenarios":"POST/PUT to a Watsonx Orchestrate deployment endpoint whose created-tool payload passes flow_version_id as a non-string, e.g. {\"flow_version_id\": 12345}, null, or an object; also calling the mapper programmatically with a raw integer id read from a DB row or config.","commonSituations":"Scripts that read the version id from a source that yields ints (e.g. some DB drivers, JSON with numeric ids); passing the whole request body or a nested object instead of the id field; None leaking in when a flow version was never created upstream.","solutions":["Pass flow_version_id as a canonical UUID string, e.g. str(flow_version.id) or str(uuid4()).","If the value comes from another API/DB, coerce with str(value) before building the payload.","Ensure the upstream step that creates the flow version actually ran and returned an id (not None).","If you already have a uuid.UUID object, pass it directly — the validator accepts UUID instances."],"exampleFix":"# before\ncreated_tool = {\"tool_id\": \"my-tool\", \"flow_version_id\": 12345}\n\n# after\nfrom uuid import UUID\ncreated_tool = {\"tool_id\": \"my-tool\", \"flow_version_id\": \"550e8400-e29b-41d4-a716-446655440000\"}\n# or: \"flow_version_id\": flow_version.id  (uuid.UUID instance)","handlingStrategy":"type-guard","validationCode":"from uuid import UUID\n\ndef ok_flow_version_id(v) -> bool:\n    return isinstance(v, (UUID, str)) and v is not None","typeGuard":"from uuid import UUID\nfrom typing import Any\n\ndef is_flow_version_id(v: Any) -> TypeGuard[UUID | str]:\n    return isinstance(v, UUID) or isinstance(v, str)","tryCatchPattern":"Wrap the deployment-create call in try/except pydantic.ValidationError and inspect e.errors()[0]['msg'] to distinguish 'must be provided as' (wrong type) from 'must be a valid UUID' (bad string).","preventionTips":["Always build Watsonx tool payloads with str(flow_version.id) so the type is fixed at the source.","Assert the id is present right after flow-version creation and fail loudly there, not in the mapper."],"tags":["pydantic","validation","watsonx","deployment","uuid"],"backgroundTag":null,"analyzedSha":"976ec789d2886a86de109c044d089d68e96c9a35","analyzedAt":"2026-08-14T18:23:12.227Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}