mlflow/mlflow · error · MlflowException

Cannot get input dict for schema without names.

Error message

Cannot get input dict for schema without names.

What it means

Schema.input_dict() maps column names to ColSpec/TensorSpec objects and requires named inputs. Calling it on an unnamed schema raises, since there is no name to index by.

Source

Thrown at mlflow/types/schema.py:1047

    def has_input_names(self) -> bool:
        """Return true iff this schema declares names, false otherwise."""
        return self.inputs and self.inputs[0].name is not None

    def input_types(self) -> list[DataType | np.dtype | Array | Object]:
        """Get types for each column in the schema."""
        return [x.type for x in self.inputs]

    def input_types_dict(self) -> dict[str, DataType | np.dtype | Array | Object]:
        """Maps column names to types, iff this schema declares names."""
        if not self.has_input_names():
            raise MlflowException("Cannot get input types as a dict for schema without names.")
        return {x.name: x.type for x in self.inputs}

    def input_dict(self) -> dict[str, ColSpec | TensorSpec]:
        """Maps column names to inputs, iff this schema declares names."""
        if not self.has_input_names():
            raise MlflowException("Cannot get input dict for schema without names.")
        return {x.name: x for x in self.inputs}

    def numpy_types(self) -> list[np.dtype]:
        """Convenience shortcut to get the datatypes as numpy types."""
        if self.is_tensor_spec():
            return [x.type for x in self.inputs]
        if all(isinstance(x.type, DataType) for x in self.inputs):
            return [x.type.to_numpy() for x in self.inputs]
        raise MlflowException(
            "Failed to get numpy types as some of the inputs types are not DataType."
        )

    def pandas_types(self) -> list[np.dtype]:
        """Convenience shortcut to get the datatypes as pandas types. Unsupported by TensorSpec."""
        if self.is_tensor_spec():
            raise MlflowException("TensorSpec only supports numpy types, use numpy_types() instead")
        if all(isinstance(x.type, DataType) for x in self.inputs):
            return [x.type.to_pandas() for x in self.inputs]

View on GitHub (pinned to 6a27f2decc)

Solutions

  1. Rebuild the schema with named ColSpec/TensorSpec entries
  2. Guard with schema.has_input_names() and iterate schema.inputs directly otherwise
  3. Access schema.inputs[0] for single unnamed-column schemas

Example fix

// before
spec = schema.input_dict()["features"]
// after
if schema.has_input_names():
    spec = schema.input_dict()["features"]
else:
    spec = schema.inputs[0]
Defensive patterns

Strategy: try-catch

Validate before calling

if not schema.has_input_names():
    raise ValueError("input_dict requires a named schema")

Type guard

def can_lookup_by_name(schema, name) -> bool:
    return schema.has_input_names() and name in schema.input_names()

Try / catch

try:
    spec = schema.input_dict()["features"]
except MlflowException:
    spec = schema.inputs[0]  # unnamed single-column schema

Prevention

When it happens

Trigger: schema.input_dict() on a schema built from unnamed specs, e.g. Schema([TensorSpec(np.dtype("float64"), (-1, 4))]).

Common situations: Looking up a spec by name in a signature inferred from a bare numpy array; a serving path that assumes named inputs but loads an unnamed-column model signature.

Related errors


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