Skip to main content

How to Read the Error an MLflow Model Server Returns

· 8 min read
Jagdish Kumawat
Founder @ Dewiride

When an MLflow model server can't use a request, it says why: an HTTP status code, and, for problems with the data, a JSON body with an error_code and a message. Reading both tells a program, or you, what to fix. This guide sends three bad requests to a served model and reads each answer, with real output from MLflow 3.18.0.

Syntax​

Syntax
{"error_code": CODE, "message": TEXT, "sqlstate": STATE, "error_class": CLASS}
PartWhat it means
HTTP status400 Bad Request for data the model can't use; other codes for other problems, listed below
error_codeMLflow's name for the problem, such as INVALID_PARAMETER_VALUE or BAD_REQUEST
messageWhat went wrong; for a schema problem, the last sentence names the column
sqlstate, error_classA code and a class for the error; the class is more specific, such as SCHEMA_ENFORCEMENT_FAILED

curl -i prints the status line with the body. In PowerShell, Invoke-RestMethod shows the body as an error.

Prerequisites​

  • An MLflow tracking server at http://127.0.0.1:8080, such as mlflow server --port 8080.
  • mlflow and scikit-learn in your project, for example with uv add mlflow scikit-learn pandas.

Step 1: Log a Model and Serve It​

The example predicts a man's weight from his chin-ups, sit-ups and jumps, from scikit-learn's Linnerud dataset, so its signature has three columns: Chins, Situps and Jumps.

The log_error_model.py script in a macOS-style code window: the Linnerud exercise columns as float64, the Weight target, and a LinearRegression logged with an input example.

log_error_model.py
import mlflow
from sklearn.datasets import load_linnerud
from sklearn.linear_model import LinearRegression

mlflow.set_tracking_uri("http://127.0.0.1:8080")
mlflow.set_experiment("error-response-example")

linnerud = load_linnerud(as_frame=True)
X = linnerud.data.astype("float64") # Chins, Situps and Jumps
y = linnerud.target["Weight"]
model = LinearRegression().fit(X, y)
with mlflow.start_run():
info = mlflow.sklearn.log_model(model, name="model", input_example=X.head(3))
print("Model URI:", info.model_uri)
Terminal
uv run python log_error_model.py
Output (last line)
Model URI: models:/m-00ac13c87dea419cb9119a7ad83b6eae

Serve it on port 5001 in a second terminal, as in How to Serve an MLflow Model as a REST API with mlflow models serve:

Terminal 2
uv run mlflow models serve -m "models:/m-00ac13c87dea419cb9119a7ad83b6eae" -p 5001 --env-manager uv

Step 2: A Missing Column​

A row without Situps:

Terminal 3
curl -i http://127.0.0.1:5001/invocations -H "Content-Type: application/json" --data '{"dataframe_records": [{"Chins": 5, "Jumps": 60}]}'
Output
HTTP/1.1 400 Bad Request
date: Thu, 26 Nov 2026 04:57:30 GMT
server: uvicorn
content-length: 400
content-type: application/json

{"error_code": "INVALID_PARAMETER_VALUE", "message": "Failed to predict data ' Chins Jumps\n0 5.0 60.0'. \nError: Failed to enforce schema of data ' Chins Jumps\n0 5.0 60.0' with schema '['Chins': double (required), 'Situps': double (required), 'Jumps': double (required)]'. Error: Model is missing inputs ['Situps'].", "sqlstate": "KAM01", "error_class": "SCHEMA_ENFORCEMENT_FAILED"}

curl -i's output in a terminal: HTTP/1.1 400 Bad Request and a JSON body with error_code INVALID_PARAMETER_VALUE, a message ending in Model is missing inputs ['Situps'], sqlstate KAM01 and error_class SCHEMA_ENFORCEMENT_FAILED.

The message shows the data as the server read it, then the model's schema, 'Situps': double (required) among the three, and ends with the reason: Model is missing inputs ['Situps']. PowerShell writes each ' inside the message as \u0027, its JSON escape.

Step 3: Text Where a Number Should Be​

Terminal 3
curl -i http://127.0.0.1:5001/invocations -H "Content-Type: application/json" --data '{"dataframe_records": [{"Chins": "five", "Situps": 162, "Jumps": 60}]}'
Output
HTTP/1.1 400 Bad Request
date: Thu, 26 Nov 2026 04:57:30 GMT
server: uvicorn
content-length: 283
content-type: application/json

{"error_code": "BAD_REQUEST", "message": "Invalid input. Data is not compatible with model signature. Failed to convert column Chins to type 'float64'. Error: 'ValueError(\"could not convert string to float: 'five'\")'", "sqlstate": "KAM00", "error_class": "INVALID_PARAMETER_VALUE"}

A different error_code, BAD_REQUEST: the server couldn't turn "five" into the decimal the signature asks for, and the message names the column, Chins.

Step 4: No Layout Key​

The values alone, without dataframe_records or another of the server's four keys:

Terminal 3
curl -i http://127.0.0.1:5001/invocations -H "Content-Type: application/json" --data '{"Chins": 5, "Situps": 162, "Jumps": 60}'
Output (body shortened)
HTTP/1.1 400 Bad Request
...
{"error_code": "BAD_REQUEST", "message": "The input must be a JSON dictionary with exactly one of the input fields {'dataframe_split', 'instances', 'inputs', 'dataframe_records'}. Received dictionary with input fields: []. IMPORTANT: The MLflow Model scoring protocol has changed in MLflow version 2.0. ...", "sqlstate": "KAM00", "error_class": "INVALID_PARAMETER_VALUE"}

The server found none of its four keys. The message also says the request layout changed in MLflow 2.0, because MLflow 1 took a different one.

Other Answers You Can Get​

These don't come with the JSON body above:

StatusBodyWhen
415 Unsupported Media TypeThis predictor only supports the following content types: ...The Content-Type isn't application/json, text/csv or application/vnd.apache.parquet
405 Method Not Allowed{"detail":"Method Not Allowed"}A GET to /invocations, which takes only POST
504 Gateway TimeoutRequest processing time exceeded limitThe prediction took longer than the server's timeout: How to Set the Request Timeout of an MLflow Model Server

Common Mistakes​

MistakeWhat happensDo this instead
Reading only the first line of the messageIt repeats the data, so the reason is at the endRead the last sentence, after the final Error:
Treating every 400 the sameINVALID_PARAMETER_VALUE and BAD_REQUEST point at different fixesCheck error_code and error_class

Troubleshooting​

SymptomLikely causeFix
Model is missing inputs [...]. Note that there were extra inputs: [...]A column name has a typo, or a CSV file has no headerUse the names in the model's signature
The answer has a stack_trace fieldSome parsing errors, such as a bad CSV value, include the server's traceback, with its file pathsDon't show it to users, and don't expose the server to people you don't trust

FAQ​

Is the error body documented?​

Not field by field in the serving guide. The server builds the body from MlflowException, MLflow's error class, so the fields are the ones above.

How does a Python program read it?​

response.json()["error_code"] and response.json()["message"]: How to Call an MLflow Model Server from Python.

Conclusion​

A missing Situps came back as 400 with INVALID_PARAMETER_VALUE, SCHEMA_ENFORCEMENT_FAILED and the reason at the end of the message; "five" in Chins as 400 with BAD_REQUEST; and a request without a layout key as 400 with a note that the protocol changed in 2.0.

Additional Resources​