mlflow/mlflow · error · MlflowException
Record {i} is missing required 'inputs' field or it is empty
Error message
Record {i} is missing required 'inputs' field or it is empty What it means
Raised during prompt optimization when a training record lacks the 'inputs' field or it is empty/None. Optimization needs per-record inputs to run the predict_fn and scorers, so MLflow validates the train_data (DataFrame) before proceeding and fails fast on malformed rows.
Source
Thrown at mlflow/genai/optimize/util.py:104
def validate_train_data(
train_data: "pd.DataFrame",
scorers: list[Scorer] | None,
predict_fn: Callable[..., Any] | None = None,
) -> None:
"""
Validate that training data has required fields for prompt optimization.
Args:
train_data: Training data as a pandas DataFrame.
scorers: Scorers to validate the training data for. Can be None for zero-shot mode.
predict_fn: The predict function to validate the training data for.
Raises:
MlflowException: If any record is missing required 'inputs' field or it is empty.
"""
for i, record in enumerate(train_data.to_dict("records")):
if "inputs" not in record or not record["inputs"]:
raise MlflowException.invalid_parameter_value(
f"Record {i} is missing required 'inputs' field or it is empty"
)
if scorers is not None:
builtin_scorers = [scorer for scorer in scorers if isinstance(scorer, BuiltInScorer)]
valid_data_for_builtin_scorers(train_data, builtin_scorers, predict_fn)
def infer_type_from_value(value: Any, model_name: str = "Output") -> type:
"""
Infer the type from the value.
Only supports primitive types, lists, and dict and Pydantic models.
"""
if value is None:
return type(None)
elif isinstance(value, (bool, int, float, str)):
return type(value)
elif isinstance(value, list):View on GitHub (pinned to 6a27f2decc)
Solutions
- Rename/add the 'inputs' column to train_data so every row has it
- Drop or fix rows where inputs is None/empty, e.g. df = df[df['inputs'].apply(lambda x: bool(x))]
- Verify the DataFrame passed to optimize_prompts is the one produced by to_df()/the expected schema, not a differently-shaped frame
Example fix
// before
train_data = pd.DataFrame({"input": [{"question": "q"}], "expectations": [{}]})
// after
train_data = pd.DataFrame({"inputs": [{"question": "q"}], "expectations": [{}]}) Defensive patterns
Strategy: validation
Validate before calling
import pandas as pd
missing = train_data[~train_data["inputs"].apply(lambda x: bool(x))]
if not missing.empty:
raise ValueError(f"Rows missing/empty 'inputs': {missing.index.tolist()}") Type guard
def has_inputs(record: dict) -> bool:
return bool(record.get("inputs")) Try / catch
from mlflow.exceptions import MlflowException
try:
result = mlflow.genai.optimize_prompts(...)
except MlflowException as e:
if "missing required 'inputs'" in str(e):
train_data = train_data[train_data["inputs"].apply(bool)]
else:
raise Prevention
- Validate train_data schema right after building it, before any API call
- Standardize on the 'inputs' column name in data-prep code
- Drop or repair empty-input rows during dataset assembly
- Add a unit test asserting every training row has a non-empty inputs
When it happens
Trigger: Calling mlflow.genai.optimize_prompts (via validate_train_data) with a train_data DataFrame whose 'inputs' column is absent, or where a row's 'inputs' is None or an empty value (e.g. empty dict/string).
Common situations: Building training data with inconsistent column names (e.g. 'input' instead of 'inputs'); rows filtered down until some have no inputs; concatenating datasets where one batch lacks the column; constructing records programmatically with None placeholders.
Understand the failure class
Background: "Missing required field" and "field is required" errors: why libraries reject payloads that omit mandatory fields — this error's family across 20 libraries.
Related errors
- INVALID_PARAMETER_VALUE
- INVALID_PARAMETER_VALUE
- INVALID_PARAMETER_VALUE
- SerializedScorer cannot have multiple types of scorer fields
- Failed to deserialize InstructionsJudge scorer '{serialized.
AI-assisted analysis of mlflow/mlflow@6a27f2decc (2026-08-29).
Data as JSON: /api/errors/773a6c483ae88107.
Report an issue: GitHub.