Fixed: "MlflowException: The saved sklearn model references untrusted types"
I logged a gradient-boosted scikit-learn model with mlflow.sklearn.log_model, a call that had worked for a linear regression, and it failed with mlflow.exceptions.MlflowException: The saved sklearn model references untrusted types. MLflow 3.18.0 saves scikit-learn models in the skops format by default, then loads the file back to make sure it can. This model holds a type skops doesn't trust unless you say so. Passing that type, reviewed, in skops_trusted_types fixed it.
What I Was Doing
The shopper model of the MLflow series is a HistGradientBoostingClassifier. Here's the same failure with a smaller model: a HistGradientBoostingRegressor trained on scikit-learn's diabetes data, on MLflow 3.18.0 and scikit-learn 1.9.1, logged the plain way:
import mlflow
from sklearn.datasets import load_diabetes
from sklearn.ensemble import HistGradientBoostingRegressor
mlflow.set_tracking_uri("http://127.0.0.1:8080")
mlflow.set_experiment("untrusted-types-demo")
X, y = load_diabetes(return_X_y=True, as_frame=True)
model = HistGradientBoostingRegressor(random_state=0).fit(X, y)
with mlflow.start_run():
mlflow.sklearn.log_model(model, name="diabetes-model", input_example=X.head(3))
uv run python log_untrusted.py
What I Expected
A logged model, as with the linear regression in How to Log a scikit-learn Model in MLflow.
What I Got
Two tracebacks. The first ends in skops, the library that saves the model; the second, raised while handling it, is MLflow's:
🏃 View run popular-shad-827 at: http://127.0.0.1:8080/#/experiments/22/runs/829ee6686a804bbda1ab8c06aae4fafd
🧪 View experiment at: http://127.0.0.1:8080/#/experiments/22
Traceback (most recent call last):
File "/Users/you/source/mlflow-demo/.venv/lib/python3.15/site-packages/mlflow/sklearn/__init__.py", line 706, in _save_model
skops.io.load(output_path, trusted=skops_trusted_types)
...
skops.io.exceptions.UntrustedTypesFoundException: Untrusted types found in the file: ['sklearn.ensemble._hist_gradient_boosting.predictor.TreePredictor'].
...
During handling of the above exception, another exception occurred:
...
mlflow.exceptions.MlflowException: The saved sklearn model references untrusted types. If you are sure loading these types is safe, set the 'skops_trusted_types' parameter when calling 'log_model' or 'save_model' to the list of trusted types. Root error: Untrusted types found in the file: ['sklearn.ensemble._hist_gradient_boosting.predictor.TreePredictor'].
- sklearn.ensemble._hist_gradient_boosting.predictor.TreePredictor: sklearn.ensemble._hist_gradient_boosting.predictor.TreePredictor (used by HistGradientBoosting* models) stores raw node indices (left, right, feature_idx) in its nodes array that scikit-learn indexes into without bounds checking. A malicious file can set these to out-of-range values: skops loads the object successfully, but calling .predict() on it can then crash the process (segfault) or read out-of-bounds memory. If you created the file yourself or otherwise fully trust its source, you can load it with trusted=["sklearn.ensemble._hist_gradient_boosting.predictor.TreePredictor"].
Only add the specific types you have reviewed and trust to the `trusted` argument; avoid passing everything reported by get_untrusted_types() just to make a file load.

Nothing usable was logged: the run popular-shad-827 and its model both ended with the status FAILED.
What I Checked
Which format the model was saved in. I hadn't asked for skops. The reference for mlflow.sklearn.log_model says of serialization_format: "If not specified, the model is serialized as "cloudpickle" in Databricks Runtime or when using a Databricks tracking URI, and as "skops" otherwise. The "skops" format guarantees safe deserialization."
What MLflow does with the file. The first traceback points at _save_model in mlflow/sklearn/__init__.py. It saves the model with skops.io.dump, then loads it back with skops.io.load(output_path, trusted=skops_trusted_types). When skops raises UntrustedTypesFoundException, MLflow deletes the saved files and raises this MlflowException instead.
The type it names. TreePredictor is the object each tree of a HistGradientBoosting* model is stored in. skops's own explanation, at the end of the message, says why it isn't trusted by default, and how to trust it when you made the file yourself.
Why It Happens
skops loads only the types on its allow-list, plus any you pass as trusted. MLflow checks every skops file it saves by loading it back with your skops_trusted_types, so a model it couldn't load later is never logged. A HistGradientBoosting* model holds TreePredictor objects, which aren't on the list, and without skops_trusted_types the check fails. A linear regression holds only types skops trusts, which is why the same call worked for one.
The Fix
Review the types skops names, then pass the ones you trust to log_model:

import mlflow
from sklearn.datasets import load_diabetes
from sklearn.ensemble import HistGradientBoostingRegressor
mlflow.set_tracking_uri("http://127.0.0.1:8080")
mlflow.set_experiment("untrusted-types-demo")
# Reviewed: the trees of a HistGradientBoosting model, which skops doesn't trust by default.
TRUSTED_TYPES = ["sklearn.ensemble._hist_gradient_boosting.predictor.TreePredictor"]
X, y = load_diabetes(return_X_y=True, as_frame=True)
model = HistGradientBoostingRegressor(random_state=0).fit(X, y)
with mlflow.start_run():
model_info = mlflow.sklearn.log_model(
model, name="diabetes-model", input_example=X.head(3), skops_trusted_types=TRUSTED_TYPES
)
print("Logged", model_info.model_uri)
The list holds exactly the type skops named, written out after reading its explanation: I trained this model myself, so I trust its source. For a model whose types you don't know yet, How to Find the Untrusted Types in a scikit-learn Model with skops lists them with skops.io.get_untrusted_types.
After the Fix
uv run python log_trusted.py
2026/11/21 14:27:31 INFO mlflow.utils.uv_utils: Detected uv project: found uv.lock and pyproject.toml in /Users/you/source/mlflow-demo
2026/11/21 14:27:32 INFO mlflow.utils.uv_utils: Detected uv project: found uv.lock and pyproject.toml in /Users/you/source/mlflow-demo
2026/11/21 14:27:32 INFO mlflow.utils.environment: Detected uv project at /Users/you/source/mlflow-demo. Attempting to export requirements via 'uv export'.
2026/11/21 14:27:32 INFO mlflow.utils.uv_utils: Exported 91 dependencies via uv
2026/11/21 14:27:32 INFO mlflow.utils.environment: Successfully exported 91 requirements from uv project. Skipping package capture based inference.
🏃 View run lyrical-wren-780 at: http://127.0.0.1:8080/#/experiments/22/runs/5d9327a12f9e40f3b9cd827e7d741cd1
🧪 View experiment at: http://127.0.0.1:8080/#/experiments/22
Logged models:/m-e0c0975388a7410196eca5c70a5e88e7

The model was logged, with the status READY. MLflow keeps the list in the model's MLmodel file and loads the model with it, so whoever loads it later needs only its URI: How to Save a scikit-learn Model in the skops Format with MLflow shows the file.
Common Mistakes
| Mistake | What happens | Do this instead |
|---|---|---|
Trusting every type get_untrusted_types reports, unread | The protection skops gives is gone | Review each type and write out the list |
serialization_format="cloudpickle" to make the error go away | The model can run code when it's loaded, and MLflow warns that pickle formats need caution | Keep skops and list the reviewed types |
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
Encountered unexpected error during sklearn autologging: The saved sklearn model references untrusted types | Autologging in the skops format, which has no skops_trusted_types | Fixed: Encountered unexpected error during sklearn autologging |
skops.io.exceptions.UntrustedTypesFoundException from skops.io.load | The same check, in your own skops code | Pass the reviewed list as trusted= |
A run and its model show FAILED | log_model raised inside the run | Read the error, fix it and log again |
FAQ
Which models need skops_trusted_types?
Those that hold a type outside skops's allow-list, such as the TreePredictor of HistGradientBoosting* models. A linear regression doesn't: How to Log a scikit-learn Model in MLflow logs one in the skops format with skops_trusted_types: null.
Is it safe to trust TreePredictor?
For a model you trained yourself, or one from a source you fully trust, yes: that's what skops's explanation says. The risk it describes comes from a file someone else crafted.
Conclusion
log_model saved the gradient-boosted model in the skops format, MLflow's default outside Databricks, then refused it because skops wouldn't load its TreePredictor objects. Listing that one reviewed type in skops_trusted_types let MLflow log the model, and the list travels with it in MLmodel.
Additional Resources
- mlflow.sklearn —
log_model'sserialization_formatandskops_trusted_types. - Secure persistence with skops — trusted types.
