mlflow/mlflow · error

Unsupported input type: {type(data)}. It must be one of [str

Error message

Unsupported input type: {type(data)}. It must be one of [str, dict, list, numpy.ndarray, pandas.DataFrame]

What it means

When the saved model is a query engine or retriever, MLflow's pyfunc wrapper converts predict() input into a llama_index QueryBundle. Only str, dict, list, numpy.ndarray, and pandas.DataFrame inputs are recognized; anything else falls through to the final else and raises ValueError.

Source

Thrown at mlflow/llama_index/pyfunc_wrapper.py:53

    return data


def _format_predict_input_query_engine_and_retriever(data) -> "QueryBundle":
    """Convert pyfunc input to a QueryBundle."""
    from llama_index.core import QueryBundle

    data = _convert_llm_input_data_with_unwrapping(data)

    if isinstance(data, str):
        return QueryBundle(query_str=data)
    elif isinstance(data, dict):
        return QueryBundle(**data)
    elif isinstance(data, list):
        # NB: handle pandas returning lists when there is a single row
        prediction_input = [_format_predict_input_query_engine_and_retriever(d) for d in data]
        return prediction_input if len(prediction_input) > 1 else prediction_input[0]
    else:
        raise ValueError(
            f"Unsupported input type: {type(data)}. It must be one of "
            "[str, dict, list, numpy.ndarray, pandas.DataFrame]"
        )


class _LlamaIndexModelWrapperBase:
    def __init__(
        self,
        llama_model,  # Engine or Workflow
        model_config: dict[str, Any] | None = None,
    ):
        self._llama_model = llama_model
        self.model_config = model_config or {}

    @property
    def index(self):
        return self._llama_model.index

View on GitHub (pinned to 6a27f2decc)

Solutions

  1. Coerce the input to one of the supported types: str for a plain query, dict for structured query fields (query_str etc.), list of any of these, numpy.ndarray, or pandas.DataFrame.
  2. For a tensor, call x.detach().cpu().numpy() before predict().
  3. For a Series, wrap with pd.DataFrame(series) or convert to a list.
  4. If you're batching queries, pass a list of strings or a DataFrame with one query per row.
  5. If you need richer input, construct a dict whose keys match QueryBundle fields (e.g. {"query_str": "..."}).

Example fix

// before
import numpy as np
pred = model.predict(("query one", "query two"))  # tuple, not list
// after
pred = model.predict(["query one", "query two"])
Defensive patterns

Strategy: type-guard

Validate before calling

import numpy as np
import pandas as pd
ALLOWED = (str, dict, list, np.ndarray, pd.DataFrame)
if not isinstance(data, ALLOWED):
    data = _coerce(data)  # e.g. tuple->list, tensor->numpy

Type guard

from typing import Any
import numpy as np
import pandas as pd
def is_valid_query_input(x: Any) -> bool:
    return isinstance(x, (str, dict, list, np.ndarray, pd.DataFrame))

Try / catch

try:
    return model.predict(data)
except ValueError as e:
    if str(e).startswith("Unsupported input type"):
        data = coerce_input(data)
        return model.predict(data)
    raise

Prevention

When it happens

Trigger: Calling model.predict(x) (or pyfunc.predict) on a QueryEngineWrapper/RetrieverEngineWrapper with an unsupported type such as a tuple, set, torch.Tensor, scipy sparse matrix, PIL image, or a custom object.

Common situations: Passing a tuple instead of a list; passing a Dataset/dataloader batch tensor instead of converting to numpy first; a DataFrame column (pandas Series) rather than a full DataFrame; calling model.predict on multiple items in a Python tuple from an earlier pipeline step.

Related errors


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