{"record":{"id":"ad29b160b08bdd47","repo":"mlflow/mlflow","slug":"argument-mlflow-model-should-be-mlflow-models-mo","errorCode":null,"errorMessage":"Argument 'mlflow_model' should be mlflow.models.Model, got '{type(mlflow_model)}'","messagePattern":"Argument 'mlflow_model' should be mlflow\\.models\\.Model, got '(.+?)'","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"mlflow/store/tracking/file_store.py","lineNumber":1281,"sourceCode":"                        model_id=metric.model_id,\n                        run_id=run_id,\n                        metric=metric,\n                    )\n            for tag in tags:\n                # NB: If the tag run name value is set, update the run info to assure\n                # synchronization.\n                if tag.key == MLFLOW_RUN_NAME:\n                    run_status = RunStatus.from_string(run_info.status)\n                    self.update_run_info(run_id, run_status, run_info.end_time, tag.value)\n                self._set_run_tag(run_info, tag)\n        except Exception as e:\n            raise MlflowException(e, INTERNAL_ERROR)\n\n    def record_logged_model(self, run_id, mlflow_model):\n        from mlflow.models import Model\n\n        if not isinstance(mlflow_model, Model):\n            raise TypeError(\n                f\"Argument 'mlflow_model' should be mlflow.models.Model, got '{type(mlflow_model)}'\"\n            )\n        _validate_run_id(run_id)\n        run_info = self._get_run_info(run_id)\n        check_run_is_active(run_info)\n        model_dict = mlflow_model.get_tags_dict()\n        run_info = self._get_run_info(run_id)\n        path = self._get_tag_path(run_info.experiment_id, run_info.run_id, MLFLOW_LOGGED_MODELS)\n        if os.path.exists(path):\n            with open(path) as f:\n                model_list = json.loads(f.read())\n        else:\n            model_list = []\n        tag = RunTag(MLFLOW_LOGGED_MODELS, json.dumps(model_list + [model_dict]))\n\n        try:\n            self._set_run_tag(run_info, tag)\n        except Exception as e:","sourceCodeStart":1263,"sourceCodeEnd":1299,"githubUrl":"https://github.com/mlflow/mlflow/blob/6a27f2decc0b76eb1b54af31849784addb357dbc/mlflow/store/tracking/file_store.py#L1263-L1299","documentation":"FileStore.record_logged_model requires mlflow_model to be an instance of mlflow.models.Model and raises a plain TypeError for anything else. It is an internal API type check to prevent writing invalid logged-model tags.","triggerScenarios":"Calling FileStore.record_logged_model (or a code path that forwards into it) with a dict, an mlflow.entities.model_registry.Model, a LoggedModel, or any object that is not mlflow.models.Model.","commonSituations":"Hand-rolled logging code passing a model dict or registry model instead of a loaded mlflow.models.Model; mixing up mlflow.models.Model with mlflow.entities.Model in custom integrations; version changes where internal helpers expect Model.","solutions":["Pass an actual mlflow.models.Model instance (e.g. the object from Model.load or the model you saved)","If you have a dict, construct Model.from_dict(model_dict) before calling","Check you are importing Model from mlflow.models, not a similarly named registry entity class","Use the public mlflow.log_model / MlflowClient.log_logged_model APIs instead of the internal record_logged_model"],"exampleFix":"// before\nfrom mlflow.entities import Model\nstore.record_logged_model(run_id, model_dict)\n// after\nfrom mlflow.models import Model\nstore.record_logged_model(run_id, Model.from_dict(model_dict))","handlingStrategy":"type-guard","validationCode":"from mlflow.models import Model\nif not isinstance(mlflow_model, Model):\n    raise TypeError(\"record_logged_model requires mlflow.models.Model\")","typeGuard":"from mlflow.models import Model\ndef is_mlflow_model(obj) -> bool:\n    return isinstance(obj, Model)","tryCatchPattern":"try:\n    store.record_logged_model(run_id, model)\nexcept TypeError as e:\n    model = Model.from_dict(model_as_dict)\n    store.record_logged_model(run_id, model)","preventionTips":["Always import Model from mlflow.models, never mlflow.entities","Prefer public APIs (mlflow.log_model, MlflowClient.create_logged_model) over internal store methods","Convert dicts with Model.from_dict before passing"],"tags":["type-error","file-store","logged-models"],"backgroundTag":"wrong-argument-type","analyzedSha":"6a27f2decc0b76eb1b54af31849784addb357dbc","analyzedAt":"2026-08-29T20:54:51.419Z","schemaVersion":2},"datasetVersion":"2026-08-29T22:17:34.462Z"}