{"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":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"scripts/check-provider-registry.py","lineNumber":136,"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.\n    for variant_name, id_literal in [\n        (\"Deepseek\", \"deepseek\"),\n        (\"DeepseekAnthropic\", \"deepseek-anthropic\"),\n        (\"OpenaiCodex\", \"openai-codex\"),\n        (\"Anthropic\", \"anthropic\"),\n        (\"Openmodel\", \"openmodel\"),\n        (\"MinimaxAnthropic\", \"minimax-anthropic\"),","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/8880682c63083a91624de936797efa3ce9e498fd/scripts/check-provider-registry.py#L118-L154","documentation":"parse_aliases_for_variant could not find a parse arm mapping string literals to the requested enum variant: neither a `\"...\" => Some(Self::Variant)` pattern inside the enum's `parse` match, nor (for ProviderKind/ApiProvider) a matching provider!() macro invocation in crates/config/src/provider.rs. The checker uses these arms to verify documented aliases, so a variant without a string-parseable identity is treated as a registry inconsistency.","triggerScenarios":"Adding a new ProviderKind/ApiProvider variant without a parse arm; renaming a variant without updating parse; writing the arm with match guards, wildcards, or intermediate bindings the regex cannot match; changing the provider!() macro's argument shape so the fallback lookup misses too.","commonSituations":"New-provider onboarding done in the registry but not the parser; refactors of the parse function to data-driven lookups.","solutions":["Add the missing arm to the enum's parse function: `\"the-id\" | \"alias\" => Some(Self::Variant)` (for ProviderKind this lives in crates/config/src/provider_kind.rs)","Or add a provider!() invocation for the variant in crates/config/src/provider.rs with the id string and aliases list, which the checker also reads","Keep arms as plain string-literal patterns — guards or `_ =>` fallbacks are invisible to the check","Update the regexes in parse_aliases_for_variant if the macro shape legitimately changed"],"exampleFix":"// before: ProviderKind::Newprovider exists but parse() has no arm for it\n// after (crates/config/src/provider_kind.rs, inside parse)\n\"newprovider\" | \"new-provider\" => Some(Self::Newprovider),","handlingStrategy":"try-catch","validationCode":"assert re.search(r'=>\\s*Some\\(Self::Newprovider\\)', provider_kind_rs), 'missing parse arm for Newprovider'","typeGuard":null,"tryCatchPattern":"try:\n    aliases = parse_aliases_for_variant(...)\nexcept ValueError as e:\n    if 'missing parse arm' in str(e):\n        add_parse_arm(e)\n    raise","preventionTips":["Every new enum variant needs a string-literal parse arm","Onboard providers through provider!() so the checker sees id and aliases","Run the drift check in CI on changes to config and agent crates"],"tags":["python","rust","provider-registry","static-analysis"],"backgroundTag":null,"analyzedSha":"8880682c63083a91624de936797efa3ce9e498fd","analyzedAt":"2026-08-16T11:31:27.956Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}