mlflow/mlflow · error · MlflowException

The input column '{name}' is required by the model signature

Error message

The input column '{name}' is required by the model signature but missing from the input data.

What it means

In `_enforce_named_col_schema`, MLflow checks each column declared in the model's (named-column) signature against the input DataFrame. A column marked `required=True` in the signature is absent from the input data, so enforcement fails with this plain MlflowException. This ensures inference inputs match the schema the model was trained/logged with.

Source

Thrown at mlflow/models/utils.py:977

        # Otherwise, the schema is not valid.
        else:
            new_pf_input[x] = pd.Series(
                [_enforce_type(obj, input_types[i]) for obj in pf_input[x]], name=x
            )
    return pd.DataFrame(new_pf_input)


def _enforce_named_col_schema(pf_input: pd.DataFrame, input_schema: Schema):
    """Enforce the input columns conform to the model's column-based signature."""
    input_names = input_schema.input_names()
    input_dict = input_schema.input_dict()
    new_pf_input = {}
    for name in input_names:
        input_type = input_dict[name].type
        required = input_dict[name].required
        if name not in pf_input:
            if required:
                raise MlflowException(
                    f"The input column '{name}' is required by the model "
                    "signature but missing from the input data."
                )
            else:
                continue
        if isinstance(input_type, DataType):
            new_pf_input[name] = _enforce_mlflow_datatype(name, pf_input[name], input_type)
        # If the input_type is objects/arrays/maps, we assume pf_input must be a pandas DataFrame.
        # Otherwise, the schema is not valid.
        else:
            new_pf_input[name] = pd.Series(
                [_enforce_type(obj, input_type, required) for obj in pf_input[name]], name=name
            )
    return pd.DataFrame(new_pf_input)


def _reshape_and_cast_pandas_column_values(name, pd_series, tensor_spec):
    if tensor_spec.shape[0] != -1 or -1 in tensor_spec.shape[1:]:

View on GitHub (pinned to 6a27f2decc)

Solutions

  1. Add the missing column to the input DataFrame before predict (fill with default/zero if the model was trained with it).
  2. Rename the column to match the signature name exactly (case-sensitive).
  3. If the column is genuinely optional, re-log the model with a signature where that column is `required=False` (or inferred as optional).

Example fix

// before
df = df[["a", "b"]]
model.predict(df)  # signature also requires 'c'
// after
df["c"] = 0  # or load the real value
model.predict(df[["a", "b", "c"]])
Defensive patterns

Strategy: validation

Validate before calling

sig = model.metadata.signature
required = [c.name for c in sig.inputs.inputs if getattr(c, 'required', True)]
missing = [c for c in required if c not in df.columns]
if missing:
    raise ValueError(f"Missing required input columns: {missing}")

Try / catch

from mlflow.exceptions import MlflowException
try:
    preds = model.predict(df)
except MlflowException as e:
    if "required by the model signature but missing" in str(e):
        col = str(e).split("'")[1]
        df = df.assign(**{col: 0})
        preds = model.predict(df)
    else:
        raise

Prevention

When it happens

Trigger: Calling `model.predict(df)` (or `mlflow.pyfunc`/spark UDF paths via `_enforce_pyspark_dataframe_schema`) with a DataFrame missing a required column; renaming or dropping a column upstream; selecting a subset of columns before predict.

Common situations: Feature pipelines that drop low-importance columns after model logging; ETL schema drift; loading a parquet/CSV where a column was renamed; train/serve skew where serving data omits a feature.

Related errors


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