mlflow/mlflow · error · MlflowException

Invalid properties not defined in the schema found: {invalid

Error message

Invalid properties not defined in the schema found: {invalid_props}

What it means

Object enforcement is strict: keys present in the data that are not declared as properties in the Object schema are rejected. This prevents silent schema drift where producers add fields the model never validated. The message lists the offending extra keys.

Source

Thrown at mlflow/models/utils.py:1426

        data = None if len(data) == 0 else data.asDict(True)
    if not required and (data is None or data == {}):
        return data
    if not isinstance(data, dict):
        raise MlflowException(
            f"Failed to enforce schema of '{data}' with type '{obj}'. "
            f"Expected data to be dictionary, got {type(data).__name__}"
        )
    if not isinstance(obj, Object):
        raise MlflowException(
            f"Failed to enforce schema of '{data}' with type '{obj}'. "
            f"Expected obj to be Object, got {type(obj).__name__}"
        )
    properties = {prop.name: prop for prop in obj.properties}
    required_props = {k for k, prop in properties.items() if prop.required}
    if missing_props := required_props - set(data.keys()):
        raise MlflowException(f"Missing required properties: {missing_props}")
    if invalid_props := data.keys() - properties.keys():
        raise MlflowException(
            f"Invalid properties not defined in the schema found: {invalid_props}"
        )
    for k, v in data.items():
        try:
            data[k] = _enforce_property(v, properties[k])
        except MlflowException as e:
            raise MlflowException(
                f"Failed to enforce schema for key `{k}`. "
                f"Expected type {properties[k].to_dict()[k]['type']}, "
                f"received type {type(v).__name__}"
            ) from e
    return data


def _enforce_map(data: Any, map_type: Map, required: bool = True):
    if (not required or isinstance(map_type.value_type, AnyType)) and (data is None or data == {}):
        return data

View on GitHub (pinned to 6a27f2decc)

Solutions

  1. Strip unknown keys before enforcement: `{k: v for k, v in payload.items() if k in known_properties}`.
  2. Add the new fields as Properties in the Object schema if they are legitimate inputs.
  3. Keep the model signature in sync when upstream producers change their payload shape.
  4. Configure clients to send only the fields declared in `model.metadata.get_input_schema()`.

Example fix

// before
_enforce_object({"x": 1.0, "extra": 2}, obj)  # 'extra' undeclared

// after
payload = {k: v for k, v in raw.items() if k in {"x", "y"}}
_enforce_object(payload, obj)
Defensive patterns

Strategy: validation

Validate before calling

allowed = {p.name for p in obj.properties}
clean = {k: v for k, v in data.items() if k in allowed}  # drop extras before enforcement

Try / catch

try:
    out = _enforce_object(data, obj)
except MlflowException as e:
    if "Invalid properties not defined in the schema" in str(e):
        allowed = {p.name for p in obj.properties}
        out = _enforce_object({k: v for k, v in data.items() if k in allowed}, obj)
    else:
        raise

Prevention

When it happens

Trigger: Sending a dict containing extra/unknown keys to an Object-typed input, e.g. an audit field like 'timestamp' added by the client; forwarding raw upstream JSON (with metadata keys) straight into inference.

Common situations: API payloads enriched by gateways (request ids, timestamps) reaching the model untouched; schema updated upstream without updating the model signature; clients reusing one payload object across models with different schemas.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


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