p-e-w/heretic · error · ValueError

unknown MismatchSeverity value: {self}

Error message

unknown MismatchSeverity value: {self}

What it means

The __rich__ renderer for a MismatchSeverity value encountered an enum member it has no color mapping for. This indicates the MismatchSeverity enum was extended with a new value but the rich rendering match statement was not updated, or an out-of-range value was passed in.

Source

Thrown at src/heretic/reproduce.py:148

class MismatchSeverity(IntEnum):
    LOW = 1
    MEDIUM = 2
    HIGH = 3
    CRITICAL = 4

    def __rich__(self) -> str:
        match self:
            case MismatchSeverity.LOW:
                return "[green]low[/]"
            case MismatchSeverity.MEDIUM:
                return "[yellow]medium[/]"
            case MismatchSeverity.HIGH:
                return "[red]high[/]"
            case MismatchSeverity.CRITICAL:
                return "[bold red]critical[/]"
            case _:
                raise ValueError(f"unknown MismatchSeverity value: {self}")


def get_package_mismatch_severity(package_name: str) -> MismatchSeverity:
    if package_name in [
        "heretic-llm",
    ]:
        return MismatchSeverity.CRITICAL
    elif package_name in [
        "torch",
        "transformers",
    ]:
        return MismatchSeverity.HIGH
    elif package_name in [
        "accelerate",
        "bitsandbytes",
        "kernels",
        "optuna",
        "peft",

View on GitHub (pinned to bedb94ef11)

Solutions

  1. Upgrade heretic to a version whose __rich__ covers all MismatchSeverity members.
  2. Downgrade/align heretic-llm so the enum matches the known members.
  3. Report/patch the missing `case` arm for the new enum value.

Example fix

// before
match self:
    case MismatchSeverity.CRITICAL: return "[bold red]critical[/]"
// after
match self:
    case MismatchSeverity.CRITICAL: return "[bold red]critical[/]"
    case _: raise ValueError(f"unknown MismatchSeverity value: {self}")  # add new case before wildcard
Defensive patterns

Strategy: try-catch

Validate before calling

try:
    MismatchSeverity(getattr(sev, "value", sev))
    assert sev in {MismatchSeverity.LOW, MismatchSeverity.MEDIUM, MismatchSeverity.HIGH, MismatchSeverity.CRITICAL}
except (ValueError, AssertionError):
    pass  # treat as unknown mismatch before rendering

Type guard

def is_known_severity(s) -> bool:
    return s in {MismatchSeverity.LOW, MismatchSeverity.MEDIUM, MismatchSeverity.HIGH, MismatchSeverity.CRITICAL}

Try / catch

try:
    report.rich_output()
except ValueError as e:
    if str(e).startswith("unknown MismatchSeverity value"):
        print("heretic version out of sync with severity enum; upgrade heretic")
    else:
        raise

Prevention

When it happens

Trigger: Calling check_environment (which calls __rich__ on each MismatchSeverity) with a MismatchSeverity value outside the LOW/MEDIUM/HIGH/CRITICAL set handled by the match statement.

Common situations: Upgrading heretic or heretic-llm so the enum gains a new severity that the installed reproduce module's formatter doesn't know; custom code constructing MismatchSeverity directly.

Related errors


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