p-e-w/heretic · error · ValueError

unknown metadata.type value in version information: {metadat

Error message

unknown metadata.type value in version information: {metadata['type']}

What it means

format_version_information builds a version string from install metadata and only knows metadata.type values like pip/git/local (plus an unknown fallback for missing metadata). If metadata['type'] carries an unrecognized value, the match statement's wildcard arm raises this ValueError. It signals version metadata produced by an unsupported install mechanism.

Source

Thrown at src/heretic/reproduce.py:190

        return MismatchSeverity.LOW


def format_version_information(version_information: dict[str, Any]) -> str:
    version = version_information["version"]
    metadata = version_information["metadata"]

    if "type" in metadata:
        match metadata["type"]:
            case "pypi":
                return version
            case "git":
                return f"{version}-git+{metadata['url']}@{metadata['commit_hash']}"
            case "local":
                # Append a random number to ensure that two local installations
                # are always considered to be different versions.
                return f"{version}-local-{random.randint(2**16, 2**17)}"
            case _:
                raise ValueError(
                    f"unknown metadata.type value in version information: {metadata['type']}"
                )
    else:
        return f"{version}-unknown-{random.randint(2**16, 2**17)}"


def check_environment(
    settings: Settings,
    reproduction_information: dict[str, Any],
) -> bool | None:
    mismatch_severity: MismatchSeverity | None = None

    system_mismatches = []
    package_mismatches = []

    def verify(
        mismatch_list: list[tuple[str, Any, Any, MismatchSeverity]],
        name: str,

View on GitHub (pinned to bedb94ef11)

Solutions

  1. Upgrade heretic to a version that recognizes the new metadata.type.
  2. Reinstall heretic-llm with a supported method (pip or git) so metadata.type is a known value.
  3. Patch format_version_information to handle the new type or fall back to the unknown branch.

Example fix

// before
case _: raise ValueError(f"unknown metadata.type value in version information: {metadata['type']}")
// after
# reinstall with a supported method so type is "pip"/"git"/"local"
pip install --force-reinstall heretic-llm
Defensive patterns

Strategy: try-catch

Validate before calling

from importlib.metadata import distribution
meta = distribution("heretic-llm").read_text("METADATA")  # inspect install source before running reproduce checks

Type guard

def has_supported_version_type(metadata: dict) -> bool:
    return metadata.get("type") in {"pip", "git", "local"} or "type" not in metadata

Try / catch

try:
    report = check_environment()
except ValueError as e:
    if str(e).startswith("unknown metadata.type value"):
        print("Reinstall heretic-llm via pip/git; metadata.type not supported")
    else:
        raise

Prevention

When it happens

Trigger: Calling check_environment on an environment whose package version metadata contains a `type` value not handled by format_version_information's match cases.

Common situations: Exotic installs (conda, vendored builds) writing custom metadata.type values; a version of heretic-llm producing new metadata types the installed heretic doesn't understand.

Related errors


AI-assisted analysis of p-e-w/heretic@bedb94ef11 (2026-08-29). Data as JSON: /api/errors/1292ab5eb988a960. Report an issue: GitHub.