{"record":{"id":"cc6c6afa84412147","repo":"mlflow/mlflow","slug":"invalid-type-item-type","errorCode":null,"errorMessage":"Invalid type: {item['type']}.","messagePattern":"Invalid type: (.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"mlflow/types/responses_helpers.py","lineNumber":359,"sourceCode":"    role: str\n    status: str | None = None\n    type: str = \"message\"\n\n    @model_validator(mode=\"after\")\n    def check_content(self) -> \"Message\":\n        if self.content is None:\n            raise ValueError(\"content must not be None\")\n        if isinstance(self.content, list):\n            for item in self.content:\n                if isinstance(item, dict):\n                    if \"type\" not in item:\n                        raise ValueError(\n                            \"dictionary type content field values must have key 'type'\"\n                        )\n                    if item[\"type\"] == \"input_text\":\n                        ResponseInputTextParam(**item)\n                    elif item[\"type\"] not in {\"input_image\", \"input_file\"}:\n                        raise ValueError(f\"Invalid type: {item['type']}.\")\n        return self\n\n    @model_validator(mode=\"after\")\n    def check_role(self) -> \"Message\":\n        if self.role not in {\"user\", \"assistant\", \"system\", \"developer\"}:\n            raise ValueError(\n                f\"Invalid role: {self.role}. Must be 'user', 'assistant', 'system', or 'developer'.\"\n            )\n        return self\n\n\nclass FunctionCallOutput(Status):\n    call_id: str\n    output: str | list[dict[str, Any]]\n    type: str = \"function_call_output\"\n\n\nclass BaseRequestPayload(Truncation, ToolChoice):","sourceCodeStart":341,"sourceCodeEnd":377,"githubUrl":"https://github.com/mlflow/mlflow/blob/6a27f2decc0b76eb1b54af31849784addb357dbc/mlflow/types/responses_helpers.py#L341-L377","documentation":"check_content dispatches each dict content item by its 'type' value; only input_text (validated as ResponseInputTextParam), input_image, and input_file are accepted. Any other 'type' string raises this ValueError. OpenAI Responses-API part types like output_text or input_audio are not accepted for user input content in MLflow's schema.","triggerScenarios":"Message(content=[{'type': 'output_text', ...}]) or any dict item whose 'type' is not one of input_text/input_image/input_file, e.g. {'type': 'text', 'text': 'hi'} (Chat Completions style).","commonSituations":"Reusing Chat Completions content part types ('text', 'image_url') instead of Responses API types; passing model output parts back as input; typos like 'input_Text'.","solutions":["Rename the type to one of: input_text, input_image, input_file","For text parts include the 'text' key too, since input_text items are validated as ResponseInputTextParam(text=..., type='input_text')","Map Chat Completions parts to Responses equivalents before constructing the Message ('text' -> 'input_text', 'image_url' -> 'input_image')"],"exampleFix":"// before\nMessage(role=\"user\", content=[{\"type\": \"text\", \"text\": \"hello\"}])\n// after\nMessage(role=\"user\", content=[{\"type\": \"input_text\", \"text\": \"hello\"}])","handlingStrategy":"validation","validationCode":"ALLOWED = {\"input_text\", \"input_image\", \"input_file\"}\ndef validate_types(content):\n    for item in content if isinstance(content, list) else []:\n        if isinstance(item, dict) and item.get(\"type\") not in ALLOWED:\n            raise ValueError(f\"unsupported content type: {item.get('type')}\")\n    return True","typeGuard":"def is_valid_part(item: dict) -> bool:\n    return item.get(\"type\") in {\"input_text\", \"input_image\", \"input_file\"}","tryCatchPattern":"try:\n    msg = Message(role=role, content=content)\nexcept ValueError as e:\n    if str(e).startswith(\"Invalid type:\"):\n        bad = str(e).split(\"Invalid type: \")[1].rstrip(\".\")\n        raise TypeError(f\"Replace content part type {bad!r} with input_text/input_image/input_file\") from e\n    raise","preventionTips":["Map Chat Completions part types ('text', 'image_url') to Responses types ('input_text', 'input_image') at an API boundary","Keep a constant set of allowed part types and validate payloads against it","Only feed model outputs back as inputs after converting output parts to input parts"],"tags":["validation","responses-api","enum"],"backgroundTag":"invalid-enum-value","analyzedSha":"6a27f2decc0b76eb1b54af31849784addb357dbc","analyzedAt":"2026-08-29T20:54:51.419Z","schemaVersion":2},"datasetVersion":"2026-08-29T22:17:34.462Z"}