{"record":{"id":"28c5224c8c9013b4","repo":"Hmbown/CodeWhale","slug":"modelregistry-uses-unknown-provider-variants-sorted-missing","errorCode":null,"errorMessage":"ModelRegistry uses unknown provider variants: {sorted(missing)}","messagePattern":"ModelRegistry uses unknown provider variants: (.+?)","errorType":"console","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"scripts/check-provider-registry.py","lineNumber":531,"sourceCode":"\n    if re.search(\n        r\"\\b(?:antigravity|agy)\\b\", web_facts_generated, flags=re.IGNORECASE\n    ):\n        errors.append(\"web/lib/facts.generated.ts exposes legacy Antigravity/agy\")\n\n    return errors\n\n\ndef static_registry_provider_rows(providers_md: str) -> set[str]:\n    table = markdown_section(providers_md, \"## Static Model Registry\")\n    return set(re.findall(r\"^\\|\\s*`([^`]+)`\\s*\\|\", table, flags=re.MULTILINE))\n\n\ndef model_registry_providers(agent_rs: str, variant_to_id: dict[str, str]) -> set[str]:\n    variants = set(re.findall(r\"provider:\\s*ProviderKind::(\\w+)\", agent_rs))\n    missing = variants - set(variant_to_id)\n    if missing:\n        raise ValueError(f\"ModelRegistry uses unknown provider variants: {sorted(missing)}\")\n    return {variant_to_id[variant] for variant in variants}\n\n\ndef default_strings(tui_config_rs: str) -> set[str]:\n    # Model/base-URL constants now live in config/models.rs (#3311); scan it\n    # alongside config.rs so the check follows the leaf split.\n    sources = tui_config_rs + \"\\n\" + read(TUI_CONFIG_MODELS_RS)\n    defaults = set()\n    for name, value in re.findall(\n        r'const\\s+(DEFAULT_[A-Z0-9_]+(?:MODEL|BASE_URL)):\\s*&str\\s*=\\s*\"([^\"]+)\"',\n        sources,\n    ):\n        if name == \"DEFAULT_DEEPSEEKCN_BASE_URL\" or name.startswith(\n            \"DEFAULT_ANTIGRAVITY_\"\n        ):\n            continue\n        defaults.add(value)\n    if not defaults:","sourceCodeStart":513,"sourceCodeEnd":549,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/scripts/check-provider-registry.py#L513-L549","documentation":"model_registry_providers scans crates/agent/src/lib.rs for `provider: ProviderKind::X` occurrences and requires every variant X to be known to the ProviderKind id mapping. Unknown variants raise this ValueError. It guarantees the static ModelRegistry rows only reference real, documented provider variants.","triggerScenarios":"A ModelRegistry entry in crates/agent/src/lib.rs contains `provider: ProviderKind::SomeVariant` where SomeVariant is not in the variant_to_id map built from provider_kind.rs (variant misspelled, variant removed, or variant added only in agent.rs).","commonSituations":"Typo in a registry row after a copy-paste; a ProviderKind variant was renamed/deleted but agent/src/lib.rs still references the old name; a new variant exists in agent code before the enum was extended.","solutions":["Read the sorted variant names in the message; fix the spelling of `provider: ProviderKind::<Variant>` in crates/agent/src/lib.rs to match an existing ProviderKind variant.","If the variant is new, add it (and its parse/id mapping) to provider_kind.rs first.","If the variant was removed upstream, delete or replace the stale ModelRegistry row."],"exampleFix":"// before (agent/src/lib.rs)\nprovider: ProviderKind::OpenAi,\n// after\nprovider: ProviderKind::OpenAI,","handlingStrategy":"validation","validationCode":"import re\nagent = open(\"crates/agent/src/lib.rs\").read()\nvariants = set(re.findall(r\"provider:\\s*ProviderKind::(\\w+)\", agent))\nunknown = variants - set(variant_to_id)\nassert not unknown, f\"unknown variants: {sorted(unknown)}\"","typeGuard":"def registry_variants_known(agent_rs: str, variant_to_id: dict) -> bool:\n    return set(re.findall(r\"provider:\\s*ProviderKind::(\\w+)\", agent_rs)) <= set(variant_to_id)","tryCatchPattern":"try:\n    ids = model_registry_providers(agent_src, variant_to_id)\nexcept ValueError as e:\n    print(e); sys.exit(1)  # lists offending variants verbatim","preventionTips":["Never hand-type ProviderKind variants in registry rows; copy from provider_kind.rs or use an IDE completion.","Grep for the old variant name across crates/ when renaming or removing a ProviderKind variant.","Run the registry check as part of CI so stale rows fail fast."],"tags":["python","rust","enum","consistency-check"],"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"}