invoke-ai/InvokeAI · error · UnknownMetadataException

'{url}' does not look like a HuggingFace model page

Error message

'{url}' does not look like a HuggingFace model page

What it means

from_url parses an HF model page URL with HF_MODEL_RE to extract the org/repo id. If the URL doesn't match the expected huggingface.co/<org>/<repo> pattern, it raises UnknownMetadataException because no repo id can be derived. This is the public entry point used when importing a model by URL.

Source

Thrown at invokeai/backend/model_manager/metadata/fetch/huggingface.py:168

            id=model_info.id,
            name=name,
            files=files,
            api_response=json.dumps(model_info.__dict__, default=str),
            is_diffusers=is_diffusers,
            ckpt_urls=ckpt_urls,
        )

    def from_url(self, url: AnyHttpUrl) -> AnyModelRepoMetadata:
        """
        Return a HuggingFaceMetadata object given the model's web page URL.

        In the case of an invalid or missing URL, raises a ModelNotFound exception.
        """
        if match := re.match(HF_MODEL_RE, str(url), re.IGNORECASE):
            repo_id = match.group(1)
            return self.from_id(repo_id)
        else:
            raise UnknownMetadataException(f"'{url}' does not look like a HuggingFace model page")

View on GitHub (pinned to 0b6a024f2f)

Solutions

  1. Pass the plain model page URL: https://huggingface.co/<org>/<repo> (no /blob/, /tree/, /resolve/, or file names).
  2. If you have a direct file URL, strip everything after the repo id, or use from_id('<org>/<repo>') instead.
  3. Confirm the host is huggingface.co (or www.huggingface.co) — mirrors won't match HF_MODEL_RE.
  4. Validate the URL with the same regex before calling to give users better feedback.

Example fix

// before
meta = fetcher.from_url('https://huggingface.co/org/model/resolve/main/model.safetensors')
// after
meta = fetcher.from_url('https://huggingface.co/org/model')
Defensive patterns

Strategy: validation

Validate before calling

import re
HF_MODEL_RE = r'https?://(?:www\.)?huggingface\.co/([\w\-.]+/[\w\-.]+)(?:$|[/?#])'
def is_hf_model_url(url: str) -> bool:
    return re.match(HF_MODEL_RE, url, re.IGNORECASE) is not None

Type guard

def is_hf_model_page_url(url: object) -> bool:
    import re
    return isinstance(url, str) and re.match(
        r'https?://(?:www\.)?huggingface\.co/[\w\-.]+/[\w\-.]+(?:$|[/?#])',
        url, re.IGNORECASE) is not None

Try / catch

try:
    meta = fetcher.from_url(url)
except UnknownMetadataException:
    # URL not a HF model page; prompt user or try from_id on a manually-extracted repo id
    raise ValueError(f'{url} is not a huggingface.co/<org>/<repo> model page')

Prevention

When it happens

Trigger: Calling from_url with a non-HF URL ( Civitai, direct file links like .../resolve/main/model.safetensors, repo trees, pull requests, discussions URLs), a URL missing the org/repo path, or a typo/whitespace in the URL string.

Common situations: Pasting a direct-file download link instead of the model page; passing a mirror or hf-mirror.com domain; URLs with extra segments (blob/tree/resolve); users submitting Civitai links to an HF fetcher.

Related errors


AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29). Data as JSON: /api/errors/222e6cc5680ee884. Report an issue: GitHub.