{"record":{"id":"1fe5ae486f0a55ea","repo":"mlflow/mlflow","slug":"invalid-properties-not-defined-in-the-schema-found","errorCode":null,"errorMessage":"Invalid properties not defined in the schema found: {invalid_props}","messagePattern":"Invalid properties not defined in the schema found: (.+?)","errorType":"exception","errorClass":"MlflowException","httpStatus":null,"severity":"error","filePath":"mlflow/models/utils.py","lineNumber":1426,"sourceCode":"        data = None if len(data) == 0 else data.asDict(True)\n    if not required and (data is None or data == {}):\n        return data\n    if not isinstance(data, dict):\n        raise MlflowException(\n            f\"Failed to enforce schema of '{data}' with type '{obj}'. \"\n            f\"Expected data to be dictionary, got {type(data).__name__}\"\n        )\n    if not isinstance(obj, Object):\n        raise MlflowException(\n            f\"Failed to enforce schema of '{data}' with type '{obj}'. \"\n            f\"Expected obj to be Object, got {type(obj).__name__}\"\n        )\n    properties = {prop.name: prop for prop in obj.properties}\n    required_props = {k for k, prop in properties.items() if prop.required}\n    if missing_props := required_props - set(data.keys()):\n        raise MlflowException(f\"Missing required properties: {missing_props}\")\n    if invalid_props := data.keys() - properties.keys():\n        raise MlflowException(\n            f\"Invalid properties not defined in the schema found: {invalid_props}\"\n        )\n    for k, v in data.items():\n        try:\n            data[k] = _enforce_property(v, properties[k])\n        except MlflowException as e:\n            raise MlflowException(\n                f\"Failed to enforce schema for key `{k}`. \"\n                f\"Expected type {properties[k].to_dict()[k]['type']}, \"\n                f\"received type {type(v).__name__}\"\n            ) from e\n    return data\n\n\ndef _enforce_map(data: Any, map_type: Map, required: bool = True):\n    if (not required or isinstance(map_type.value_type, AnyType)) and (data is None or data == {}):\n        return data\n","sourceCodeStart":1408,"sourceCodeEnd":1444,"githubUrl":"https://github.com/mlflow/mlflow/blob/6a27f2decc0b76eb1b54af31849784addb357dbc/mlflow/models/utils.py#L1408-L1444","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Strip unknown keys before enforcement: `{k: v for k, v in payload.items() if k in known_properties}`.","Add the new fields as Properties in the Object schema if they are legitimate inputs.","Keep the model signature in sync when upstream producers change their payload shape.","Configure clients to send only the fields declared in `model.metadata.get_input_schema()`."],"exampleFix":"// before\n_enforce_object({\"x\": 1.0, \"extra\": 2}, obj)  # 'extra' undeclared\n\n// after\npayload = {k: v for k, v in raw.items() if k in {\"x\", \"y\"}}\n_enforce_object(payload, obj)","handlingStrategy":"validation","validationCode":"allowed = {p.name for p in obj.properties}\nclean = {k: v for k, v in data.items() if k in allowed}  # drop extras before enforcement","typeGuard":null,"tryCatchPattern":"try:\n    out = _enforce_object(data, obj)\nexcept MlflowException as e:\n    if \"Invalid properties not defined in the schema\" in str(e):\n        allowed = {p.name for p in obj.properties}\n        out = _enforce_object({k: v for k, v in data.items() if k in allowed}, obj)\n    else:\n        raise","preventionTips":["Whitelist-filter payloads at gateways so enrichment fields (request ids, timestamps) never reach the model","Version the model signature whenever producer payload shape changes","Log and drop unknown keys explicitly instead of forwarding raw upstream JSON"],"tags":["schema-validation","strict-schema","extra-fields"],"backgroundTag":"schema-validation-failed","analyzedSha":"6a27f2decc0b76eb1b54af31849784addb357dbc","analyzedAt":"2026-08-29T20:54:51.419Z","schemaVersion":2},"datasetVersion":"2026-08-29T22:17:34.462Z"}