{"record":{"id":"b570055e2cc32ff9","repo":"mlflow/mlflow","slug":"internal-error-b57005","errorCode":"INTERNAL_ERROR","errorMessage":"Unrecognized serialization format: {serialization_format}","messagePattern":"Unrecognized serialization format: (.+?)","errorType":"error_code","errorClass":"MlflowException","httpStatus":null,"severity":"error","filePath":"mlflow/sklearn/__init__.py","lineNumber":712,"sourceCode":"            shutil.rmtree(output_path, ignore_errors=True)\n            raise MlflowException(\n                \"The sklearn model could not be serialized in the skops serialization format. \"\n                \"skops does not support custom functions or classes that are not defined at the \"\n                \"top level. To work around this limitation, you can set the serialization_format \"\n                \"'cloudpickle', while exercising caution due to the possible arbitrary \"\n                \"code during model deserialization using CloudPickle.\"\n            ) from e\n        return\n\n    with open(output_path, \"wb\") as out:\n        if serialization_format == SERIALIZATION_FORMAT_PICKLE:\n            _dump_model(pickle, sk_model, out)\n        elif serialization_format == SERIALIZATION_FORMAT_CLOUDPICKLE:\n            import cloudpickle\n\n            _dump_model(cloudpickle, sk_model, out)\n        else:\n            raise MlflowException(\n                message=f\"Unrecognized serialization format: {serialization_format}\",\n                error_code=INTERNAL_ERROR,\n            )\n\n\ndef load_model(model_uri, dst_path=None):\n    \"\"\"\n    Load a scikit-learn model from a local file or a run.\n\n    Args:\n        model_uri: The location, in URI format, of the MLflow model, for example:\n\n            - ``/Users/me/path/to/local/model``\n            - ``relative/path/to/local/model``\n            - ``s3://my_bucket/path/to/model``\n            - ``runs:/<mlflow_run_id>/run-relative/path/to/model``\n            - ``models:/<model_name>/<model_version>``\n            - ``models:/<model_name>/<stage>``","sourceCodeStart":694,"sourceCodeEnd":730,"githubUrl":"https://github.com/mlflow/mlflow/blob/6a27f2decc0b76eb1b54af31849784addb357dbc/mlflow/sklearn/__init__.py#L694-L730","documentation":"mlflow.sklearn's save path dispatches on the `serialization_format` argument and only understands 'skops' and 'cloudpickle'. Any other value falls into the final else branch and raises this MlflowException with error code INTERNAL_ERROR. The output directory is not written with a usable model.","triggerScenarios":"Passing serialization_format to mlflow.sklearn.save_model/log_model (or via MLFLOW_SKLEARN_DEFAULT_SERIALIZATION_FORMAT-style config paths that ultimately reach _save_model) with a typo or unsupported value, e.g. 'pickle', 'joblib', or 'CloudPickle'.","commonSituations":"Typos in the format string; case-sensitivity mistakes ('CloudPickle' vs 'cloudpickle'); copying config from older MLflow versions or blog posts that predate the skops format.","solutions":["Set serialization_format to exactly 'skops' or 'cloudpickle' (lowercase).","Import the constants instead of hard-coding strings: from mlflow.sklearn import SERIALIZATION_FORMAT_SKOPS, SERIALIZATION_FORMAT_CLOUDPICKLE.","Check for accidental whitespace or case differences in config/env-driven values (e.g. .strip().lower() before passing)."],"exampleFix":"// before\nmlflow.sklearn.save_model(model, path, serialization_format='pickle')\n// after\nmlflow.sklearn.save_model(model, path, serialization_format='cloudpickle')","handlingStrategy":"validation","validationCode":"VALID = {'skops', 'cloudpickle'}\nassert serialization_format in VALID, f'serialization_format must be one of {VALID}, got {serialization_format!r}'","typeGuard":null,"tryCatchPattern":"try:\n    mlflow.sklearn.save_model(model, path, serialization_format=fmt)\nexcept MlflowException as e:\n    if 'Unrecognized serialization format' in str(e):\n        raise ValueError(f'Bad format {fmt!r}; use skops or cloudpickle') from e","preventionTips":["Use the module constants SERIALIZATION_FORMAT_SKOPS / SERIALIZATION_FORMAT_CLOUDPICKLE","Lowercase/strip values coming from config or env vars","Add a config schema check (pydantic/jsonschema) for serialization_format"],"tags":["sklearn","configuration","serialization-format"],"backgroundTag":"invalid-enum-value","analyzedSha":"6a27f2decc0b76eb1b54af31849784addb357dbc","analyzedAt":"2026-08-29T20:54:51.419Z","schemaVersion":2},"datasetVersion":"2026-08-29T22:17:34.462Z"}