Hmbown/CodeWhale · error · ValueError

: missing parse arm for

Error message

{context}: missing parse arm for {variant}

What it means

parse_aliases_for_variant() extracts the set of string aliases a ProviderKind variant accepts from its parse arm. This error means no regex in the function matched an arm for the requested variant, so the guard cannot determine the variant's documented aliases. The guard requires every selectable variant to have a recognizable parse arm.

Solutions

  1. Add back a recognizable parse arm for the variant (string literal aliases plus the provider! macro form the guard's regexes expect)
  2. Extend the guard's regex patterns if the parse style legitimately changed, keeping all variants covered
  3. Verify every ProviderKind variant appears in the parse impl in provider_kind.rs

Example fix

// before: parse impl has no arm for Huggingface
// after:  "hf" | "huggingface" => Some(Self::Huggingface), restored in the match
Defensive patterns

Strategy: validation

Validate before calling

missing = [v for v in all_variants if f'"{v.lower()}"' not in parse_impl]
if missing: print(f"parse arms missing for: {missing}")

Try / catch

try:
    aliases = parse_aliases_for_variant(source, enum_name, variant, context)
except ValueError as e:
    print(f"variant not parseable: {e}", file=sys.stderr)
    sys.exit(1)

Prevention

When it happens

Trigger: Running the check (via report_huggingface_coverage) when the parse impl for a variant in provider_kind.rs no longer matches any of the expected patterns — e.g. the arm was removed, the match was restructured into a form the regexes don't cover, or the variant name changed.

Common situations: Adding a new ProviderKind variant without a parse arm; rewriting parse to use a lookup table instead of match arms with string literals; renaming a variant and leaving the docs/guard out of sync.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@433685b202 (2026-09-15). Data as JSON: /api/errors/49797669f7b6ec2b. Report an issue: GitHub.

Appendix: source

Thrown at scripts/check-provider-registry.py:147

    match_arm = re.search(
        rf'((?:"[^"]+"\s*\|\s*)*"[^"]+")\s*=>\s*Some\(Self::{variant}\)',
        block,
    )
    if match_arm:
        return set(re.findall(r'"([^"]+)"', match_arm.group(1)))
    if enum_name in {"ProviderKind", "ApiProvider"}:
        provider_rs = read(PROVIDER_RS)
        provider_macro = re.search(
            rf'provider!\(\s*\n\s*\w+,\s*\n\s*{variant},\s*\n\s*"([^"]+)".*?'
            r"aliases:\s*\[(.*?)\]\s*\);",
            provider_rs,
            re.DOTALL,
        )
        if provider_macro:
            return {provider_macro.group(1)} | set(
                re.findall(r'"([^"]+)"', provider_macro.group(2))
            )
    raise ValueError(f"{context}: missing parse arm for {variant}")


def provider_kind_ids(config_rs: str) -> dict[str, str]:
    provider_rs = read(PROVIDER_RS)
    pairs = re.findall(
        r"provider!\(\s*\n\s*\w+,\s*\n\s*(\w+),\s*\n\s*\"([^\"]+)\"",
        provider_rs,
    )
    ids: dict[str, str] = {variant: provider_id for variant, provider_id in pairs}
    # Providers with non-fixed wire policy or custom auth behavior use manual
    # impls rather than the provider!() macro. Discover them by shape rather
    # than by name: a hand-maintained roster here goes stale the first time
    # someone adds a provider, which is exactly how this guard first failed
    # (it had never heard of `concentrate`).
    for variant_name, id_literal in re.findall(
        r'impl\s+Provider\s+for\s+(\w+)\s*\{.*?fn\s+id\s*\([^)]*\)[^{]*\{\s*"([^"]+)"',
        provider_rs,
        flags=re.DOTALL,

View on GitHub (pinned to 433685b202)