{"record":{"id":"49797669f7b6ec2b","repo":"Hmbown/CodeWhale","slug":"context-missing-parse-arm-for-variant","errorCode":null,"errorMessage":"{context}: missing parse arm for {variant}","messagePattern":"(.+?): missing parse arm for (.+?)","errorType":"console","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"scripts/check-provider-registry.py","lineNumber":147,"sourceCode":"    match_arm = re.search(\n        rf'((?:\"[^\"]+\"\\s*\\|\\s*)*\"[^\"]+\")\\s*=>\\s*Some\\(Self::{variant}\\)',\n        block,\n    )\n    if match_arm:\n        return set(re.findall(r'\"([^\"]+)\"', match_arm.group(1)))\n    if enum_name in {\"ProviderKind\", \"ApiProvider\"}:\n        provider_rs = read(PROVIDER_RS)\n        provider_macro = re.search(\n            rf'provider!\\(\\s*\\n\\s*\\w+,\\s*\\n\\s*{variant},\\s*\\n\\s*\"([^\"]+)\".*?'\n            r\"aliases:\\s*\\[(.*?)\\]\\s*\\);\",\n            provider_rs,\n            re.DOTALL,\n        )\n        if provider_macro:\n            return {provider_macro.group(1)} | set(\n                re.findall(r'\"([^\"]+)\"', provider_macro.group(2))\n            )\n    raise ValueError(f\"{context}: missing parse arm for {variant}\")\n\n\ndef provider_kind_ids(config_rs: str) -> dict[str, str]:\n    provider_rs = read(PROVIDER_RS)\n    pairs = re.findall(\n        r\"provider!\\(\\s*\\n\\s*\\w+,\\s*\\n\\s*(\\w+),\\s*\\n\\s*\\\"([^\\\"]+)\\\"\",\n        provider_rs,\n    )\n    ids: dict[str, str] = {variant: provider_id for variant, provider_id in pairs}\n    # Providers with non-fixed wire policy or custom auth behavior use manual\n    # impls rather than the provider!() macro. Discover them by shape rather\n    # than by name: a hand-maintained roster here goes stale the first time\n    # someone adds a provider, which is exactly how this guard first failed\n    # (it had never heard of `concentrate`).\n    for variant_name, id_literal in re.findall(\n        r'impl\\s+Provider\\s+for\\s+(\\w+)\\s*\\{.*?fn\\s+id\\s*\\([^)]*\\)[^{]*\\{\\s*\"([^\"]+)\"',\n        provider_rs,\n        flags=re.DOTALL,","sourceCodeStart":129,"sourceCodeEnd":165,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/scripts/check-provider-registry.py#L129-L165","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Add back a recognizable parse arm for the variant (string literal aliases plus the provider! macro form the guard's regexes expect)","Extend the guard's regex patterns if the parse style legitimately changed, keeping all variants covered","Verify every ProviderKind variant appears in the parse impl in provider_kind.rs"],"exampleFix":"// before: parse impl has no arm for Huggingface\n// after:  \"hf\" | \"huggingface\" => Some(Self::Huggingface), restored in the match","handlingStrategy":"validation","validationCode":"missing = [v for v in all_variants if f'\"{v.lower()}\"' not in parse_impl]\nif missing: print(f\"parse arms missing for: {missing}\")","typeGuard":null,"tryCatchPattern":"try:\n    aliases = parse_aliases_for_variant(source, enum_name, variant, context)\nexcept ValueError as e:\n    print(f\"variant not parseable: {e}\", file=sys.stderr)\n    sys.exit(1)","preventionTips":["Add a parse arm for every new ProviderKind variant","Keep alias string literals in the match arms so regexes can find them","Run the provider-registry guard after any enum change"],"tags":["python","rust","aliases","provider-registry","ci-guard"],"backgroundTag":"invalid-enum-value","analyzedSha":"433685b2024e7bc4c99e1e2e326bcad39b4d9d65","analyzedAt":"2026-09-15T12:24:24.634Z","contentChangedAt":"2026-09-15T12:24:24.634Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}