Hmbown/CodeWhale · error · ValueError
ModelRegistry uses unknown provider variants
Error message
ModelRegistry uses unknown provider variants: {sorted(missing)} What it means
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.
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.
Example fix
// before (agent/src/lib.rs) provider: ProviderKind::OpenAi, // after provider: ProviderKind::OpenAI,
Defensive patterns
Strategy: validation
Validate before calling
import re
agent = open("crates/agent/src/lib.rs").read()
variants = set(re.findall(r"provider:\s*ProviderKind::(\w+)", agent))
unknown = variants - set(variant_to_id)
assert not unknown, f"unknown variants: {sorted(unknown)}" Type guard
def registry_variants_known(agent_rs: str, variant_to_id: dict) -> bool:
return set(re.findall(r"provider:\s*ProviderKind::(\w+)", agent_rs)) <= set(variant_to_id) Try / catch
try:
ids = model_registry_providers(agent_src, variant_to_id)
except ValueError as e:
print(e); sys.exit(1) # lists offending variants verbatim Prevention
- 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.
When it happens
Trigger: 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).
Common situations: 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.
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
- ProviderKind::ALL uses unknown variants
- : missing parse arm for
- could not parse match block after
- crates/config/src/provider_kind.rs: missing…
- expected a hand-written `impl Provider for
AI-assisted analysis of Hmbown/CodeWhale@433685b202 (2026-09-15).
Data as JSON: /api/errors/28c5224c8c9013b4.
Report an issue: GitHub.
Appendix: source
Thrown at scripts/check-provider-registry.py:531
if re.search(
r"\b(?:antigravity|agy)\b", web_facts_generated, flags=re.IGNORECASE
):
errors.append("web/lib/facts.generated.ts exposes legacy Antigravity/agy")
return errors
def static_registry_provider_rows(providers_md: str) -> set[str]:
table = markdown_section(providers_md, "## Static Model Registry")
return set(re.findall(r"^\|\s*`([^`]+)`\s*\|", table, flags=re.MULTILINE))
def model_registry_providers(agent_rs: str, variant_to_id: dict[str, str]) -> set[str]:
variants = set(re.findall(r"provider:\s*ProviderKind::(\w+)", agent_rs))
missing = variants - set(variant_to_id)
if missing:
raise ValueError(f"ModelRegistry uses unknown provider variants: {sorted(missing)}")
return {variant_to_id[variant] for variant in variants}
def default_strings(tui_config_rs: str) -> set[str]:
# Model/base-URL constants now live in config/models.rs (#3311); scan it
# alongside config.rs so the check follows the leaf split.
sources = tui_config_rs + "\n" + read(TUI_CONFIG_MODELS_RS)
defaults = set()
for name, value in re.findall(
r'const\s+(DEFAULT_[A-Z0-9_]+(?:MODEL|BASE_URL)):\s*&str\s*=\s*"([^"]+)"',
sources,
):
if name == "DEFAULT_DEEPSEEKCN_BASE_URL" or name.startswith(
"DEFAULT_ANTIGRAVITY_"
):
continue
defaults.add(value)
if not defaults:View on GitHub (pinned to 433685b202)