{"record":{"id":"ddcece9fcb2b4e2d","repo":"mlflow/mlflow","slug":"unable-to-load-model-metadata-ensure-the-source-p","errorCode":null,"errorMessage":"Unable to load model metadata. Ensure the source path of the model being registered points to a valid MLflow model directory (see https://mlflow.org/docs/latest/models.html#storage-format) containing a model signature (https://mlflow.org/docs/latest/models.html#model-signature) specifying both input and output type specifications.","messagePattern":"Unable to load model metadata\\. Ensure the source path of the model being registered points to a valid MLflow model directory \\(see https://mlflow\\.org/docs/latest/models\\.html#storage-format\\) containing a model signature \\(https://mlflow\\.org/docs/latest/models\\.html#model-signature\\) specifying both input and output type specifications\\.","errorType":"exception","errorClass":"MlflowException","httpStatus":null,"severity":"error","filePath":"mlflow/store/_unity_catalog/registry/rest_store.py","lineNumber":244,"sourceCode":"def _raise_unsupported_method(method, message=None):\n    messages = [\n        f\"Method '{method}' is unsupported for models in the Unity Catalog.\",\n    ]\n    if message is not None:\n        messages.append(message)\n    raise MlflowException(\" \".join(messages))\n\n\ndef _load_model(local_model_dir):\n    # Import Model here instead of in the top level, to avoid circular import; the\n    # mlflow.models.model module imports from MLflow tracking, which triggers an import of\n    # this file during store registry initialization\n    from mlflow.models.model import Model\n\n    try:\n        return Model.load(local_model_dir)\n    except Exception as e:\n        raise MlflowException(\n            \"Unable to load model metadata. Ensure the source path of the model \"\n            \"being registered points to a valid MLflow model directory \"\n            \"(see https://mlflow.org/docs/latest/models.html#storage-format) containing a \"\n            \"model signature (https://mlflow.org/docs/latest/models.html#model-signature) \"\n            \"specifying both input and output type specifications.\"\n        ) from e\n\n\ndef get_feature_dependencies(model_dir):\n    \"\"\"\n    Gets the features which a model depends on. This functionality is only implemented on\n    Databricks. In OSS mlflow, the dependencies are always empty (\"\").\n    \"\"\"\n    model = _load_model(model_dir)\n    if (\n        model.flavors.get(\"python_function\", {}).get(\"loader_module\")\n        == mlflow.models.model._DATABRICKS_FS_LOADER_MODULE\n    ):","sourceCodeStart":226,"sourceCodeEnd":262,"githubUrl":"https://github.com/mlflow/mlflow/blob/6a27f2decc0b76eb1b54af31849784addb357dbc/mlflow/store/_unity_catalog/registry/rest_store.py#L226-L262","documentation":"Before creating or validating a model version in Unity Catalog, MLflow loads the MLmodel metadata from the model's source directory and re-raises any failure as this MlflowException. The source must be a valid MLflow model directory whose MLmodel file is loadable and carries a signature with both input and output specs. The original exception is chained ('from e').","triggerScenarios":"Registering a model (or querying feature/model-version dependencies) in UC where the artifact source is not a valid MLflow model directory, the MLmodel file is missing/corrupt, or the signature is absent/incomplete.","commonSituations":"Registering raw artifacts (e.g. a bare pickle or checkpoint dir) instead of an mlflow.*.log_model output; manually edited or truncated MLmodel files; logging models without an explicit or inferred signature.","solutions":["Log the model with a flavor API (e.g. mlflow.sklearn.log_model) including infer_signature(input, output) so MLmodel and signature exist","Verify the source path points to a directory containing a valid MLmodel file (inspect it locally after downloading artifacts)","If registering from run artifacts, pass the correct runs:/<run_id>/<artifact_path> source rather than a custom path"],"exampleFix":"// before\nwith mlflow.start_run():\n    mlflow.log_artifact(\"model.pkl\", \"model\")\n    client.create_model_version(\"m\", \"runs:/<run>/model\")\n// after\nwith mlflow.start_run():\n    mlflow.sklearn.log_model(sk_model, \"model\", signature=infer_signature(X, preds))\n    client.create_model_version(\"m\", f\"runs:/{run.info.run_id}/model\")","handlingStrategy":"validation","validationCode":"import os\nfrom mlflow.models import Model\n\ndef validate_model_source(model_dir):\n    mlmodel = os.path.join(model_dir, \"MLmodel\")\n    assert os.path.isfile(mlmodel), f\"No MLmodel at {model_dir}\"\n    m = Model.load(model_dir)\n    assert m.signature and m.signature.inputs and m.signature.outputs, \"Model must have input and output signature\"","typeGuard":null,"tryCatchPattern":"try:\n    client.create_model_version(name, source)\nexcept MlflowException as e:\n    if \"Unable to load model metadata\" in str(e):\n        raise RuntimeError(f\"Re-log the model with a flavor API and infer_signature; bad source: {source}\") from e\n    raise","preventionTips":["Always log via flavor APIs (mlflow.*.log_model), never raw artifact copies","Include infer_signature(input, output) at logging time","Inspect MLmodel locally before registering to UC"],"tags":["unity-catalog","model-registry","mlmodel","signature"],"backgroundTag":"invalid-model-metadata","analyzedSha":"6a27f2decc0b76eb1b54af31849784addb357dbc","analyzedAt":"2026-08-29T20:54:51.419Z","schemaVersion":2},"datasetVersion":"2026-08-29T22:17:34.462Z"}