mlflow/mlflow · error · MlflowException

List field type {list_type} is not supported in dataclass {d

Error message

List field type {list_type} is not supported in dataclass {dataclass.__name__}

What it means

When a dataclass field is a list, MLflow maps the list's element type via _map_field_type; only basic dtypes (str, float, int, bool, bytes, datetime/date, numpy types) and nested dataclasses are supported. An element type with no mapping, e.g. List[dict], List[Set[str]], or List[SomeEnum], raises this MlflowException.

Source

Thrown at mlflow/types/schema.py:1444

        if get_origin(effective_type) == list:
            # It's a list, check the type within the list
            list_type = get_args(effective_type)[0]
            if is_dataclass(list_type):
                dtype = _convert_dataclass_to_nested_object(list_type)  # Convert to nested Object
                inputs.append(
                    ColSpec(type=Array(dtype=dtype), name=field_name, required=not is_optional)
                )
            else:
                if dtype := _map_field_type(list_type):
                    inputs.append(
                        ColSpec(
                            type=Array(dtype=dtype),
                            name=field_name,
                            required=not is_optional,
                        )
                    )
                else:
                    raise MlflowException(
                        f"List field type {list_type} is not supported in dataclass"
                        f" {dataclass.__name__}"
                    )
        elif is_dataclass(effective_type):
            # It's a nested dataclass
            dtype = _convert_dataclass_to_nested_object(effective_type)  # Convert to nested Object
            inputs.append(
                ColSpec(
                    type=dtype,
                    name=field_name,
                    required=not is_optional,
                )
            )
        # confirm the effective type is a basic type
        elif dtype := _map_field_type(effective_type):
            # It's a basic type
            inputs.append(
                ColSpec(

View on GitHub (pinned to 6a27f2decc)

Solutions

  1. Replace List[dict] with List[NestedDataclass] where NestedDataclass is a @dataclass with typed fields
  2. Flatten or change the element type to a supported basic type (str, int, float, bool, bytes, datetime)
  3. If the data is genuinely unstructured, drop the field from the schema or use a pydantic-based signature path that supports more types

Example fix

// before
@dataclass
class Input:
    rows: List[dict]
// after
@dataclass
class Row:
    name: str
    score: float
@dataclass
class Input:
    rows: List[Row]
Defensive patterns

Strategy: validation

Validate before calling

from typing import get_type_hints, get_origin
SUPPORTED = {str, int, float, bool, bytes}
for name, t in get_type_hints(MyInput).items():
    if get_origin(t) is list:
        elem = get_args(t)[0]
        from dataclasses import is_dataclass
        if not (is_dataclass(elem) or elem in SUPPORTED):
            raise TypeError(f"List field {name}: unsupported element {elem}")

Type guard

def is_supported_list(t) -> bool:
    from typing import get_origin, get_args
    from dataclasses import is_dataclass
    return get_origin(t) is list and (is_dataclass(get_args(t)[0]) or get_args(t)[0] in {str, int, float, bool, bytes})

Try / catch

try:
    schema = convert_dataclass_to_schema(Input)
except MlflowException as e:
    if "List field type" in str(e) and "not supported" in str(e):
        logging.error("Change list element type: %s", e)
    raise

Prevention

When it happens

Trigger: A dataclass field annotated List[X] where X is not a dataclass and not in _map_field_type's mapping (e.g. List[dict], List[Union[...]], List[object], List[CustomClass]) passed to convert_dataclass_to_schema.

Common situations: Model inputs containing lists of dictionaries or heterogeneous objects; nested dicts that should have been modeled as dataclasses; using enums or third-party types inside lists.

Related errors


AI-assisted analysis of mlflow/mlflow@6a27f2decc (2026-08-29). Data as JSON: /api/errors/f34f6ae2ea85ae4b. Report an issue: GitHub.