{"record":{"id":"777a58d41c8a8971","repo":"mlflow/mlflow","slug":"unable-to-validate-the-repository-identifier-for-t","errorCode":null,"errorMessage":"Unable to validate the repository identifier for the HuggingFace model hub because the `huggingface-hub` package is not installed. Please install the package with `pip install huggingface-hub` command and retry.","messagePattern":"Unable to validate the repository identifier for the HuggingFace model hub because the `huggingface-hub` package is not installed\\. Please install the package with `pip install huggingface-hub` command and retry\\.","errorType":"exception","errorClass":"MlflowException","httpStatus":null,"severity":"error","filePath":"mlflow/utils/huggingface_utils.py","lineNumber":71,"sourceCode":"        \"Unable to fetch model commit hash from the HuggingFace model hub. \"\n        \"This is required for saving a model without base model \"\n        \"weights, while ensuring the version consistency of the model. \",\n        error_code=RESOURCE_DOES_NOT_EXIST,\n    )\n\n\ndef is_valid_hf_repo_id(maybe_repo_id: str | None) -> bool:\n    \"\"\"\n    Check if the given string is a valid HuggingFace repo identifier e.g. \"username/repo_id\".\n    \"\"\"\n\n    if not maybe_repo_id or os.path.isdir(maybe_repo_id):\n        return False\n\n    try:\n        from huggingface_hub.utils import HFValidationError, validate_repo_id\n    except ImportError:\n        raise MlflowException(\n            \"Unable to validate the repository identifier for the HuggingFace model hub \"\n            \"because the `huggingface-hub` package is not installed. Please install the \"\n            \"package with `pip install huggingface-hub` command and retry.\"\n        )\n\n    try:\n        validate_repo_id(maybe_repo_id)\n        return True\n    except HFValidationError as e:\n        _logger.warning(f\"The repository identified {maybe_repo_id} is invalid: {e}\")\n        return False\n","sourceCodeStart":53,"sourceCodeEnd":83,"githubUrl":"https://github.com/mlflow/mlflow/blob/6a27f2decc0b76eb1b54af31849784addb357dbc/mlflow/utils/huggingface_utils.py#L53-L83","documentation":"is_valid_hf_repo_id() validates a string as a HuggingFace repo id using huggingface_hub.utils.validate_repo_id. Because huggingface_hub is an optional dependency, its absence triggers an MlflowException telling the user to pip install huggingface-hub before MLflow can perform the validation.","triggerScenarios":"Calling mlflow.huggingface.save_model (or is_valid_hf_repo_id directly) with a non-empty, non-directory string repo id in an environment where `from huggingface_hub.utils import HFValidationError, validate_repo_id` raises ImportError.","commonSituations":"Lightweight deployments or skinny MLflow installs without the transformers/huggingface extras; forgot to add huggingface-hub to requirements before pushing to a remote registry sync flow.","solutions":["Install the package: pip install huggingface-hub (or mlflow[transformers])","Add huggingface-hub to your project's requirements/environment definition","If you are saving local files instead of a hub repo, pass a local directory path rather than a repo id string so validation is skipped"],"exampleFix":"// before\nmlflow.huggingface.save_model(model, \"my-model\")  # MlflowException: huggingface-hub not installed\n// after\n# pip install huggingface-hub\nmlflow.huggingface.save_model(model, \"my-model\")","handlingStrategy":"validation","validationCode":"try:\n    from huggingface_hub.utils import validate_repo_id  # noqa: F401\nexcept ImportError:\n    raise SystemExit('Install huggingface-hub to validate/save hub repo ids')","typeGuard":null,"tryCatchPattern":"try:\n    mlflow.huggingface.save_model(model, repo_id)\nexcept MlflowException as e:\n    if 'huggingface-hub' in str(e):\n        subprocess.run(['pip', 'install', 'huggingface-hub'], check=True)\n        mlflow.huggingface.save_model(model, repo_id)\n    else:\n        raise","preventionTips":["Include huggingface-hub in deployment requirements","Distinguish local paths (skip validation) from hub repo ids in your code","Run a dependency check at app startup in environments that save HF models"],"tags":["missing-dependency","huggingface","validation","import-error"],"backgroundTag":"missing-optional-dependency","analyzedSha":"6a27f2decc0b76eb1b54af31849784addb357dbc","analyzedAt":"2026-08-29T20:54:51.419Z","schemaVersion":2},"datasetVersion":"2026-08-29T22:17:34.462Z"}