Hmbown/CodeWhale · error · ValueError

ModelRegistry uses unknown provider variants: {sorted(missin

Error message

ModelRegistry uses unknown provider variants: {sorted(missing)}

What it means

model_registry_providers scans crates/agent/src/lib.rs for `provider: ProviderKind::<Variant>` entries and found variants absent from the variant-to-id map built from provider.rs (provider!() macros plus the manually listed impls). The static ModelRegistry may only reference providers that exist in the config crate with a known canonical id. The message lists the exact unknown variants.

Source

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

    table = markdown_section(providers_md, "## Shipped Providers")
    return set(re.findall(r"^\|\s*`([^`]+)`\s*\|", table, flags=re.MULTILINE))


def shipped_provider_tables(providers_md: str) -> set[str]:
    table = markdown_section(providers_md, "## Shipped Providers")
    return set(re.findall(r"\|\s*`\[providers\.([a-z0-9_]+)\]`\s*\|", table))


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":
            continue
        defaults.add(value)
    if not defaults:
        raise ValueError("no default provider model/base URL constants found")
    return defaults

View on GitHub (pinned to 8880682c63)

Solutions

  1. For each listed variant, register the provider in crates/config/src/provider.rs via provider!() or a manual impl, extending the manual-impl list in provider_kind_ids() when the impl is hand-written
  2. Fix typos or stale names in the `provider: ProviderKind::...` entries of crates/agent/src/lib.rs
  3. Re-run the script; the docs table comparison only proceeds once variants resolve

Example fix

// before (crates/agent/src/lib.rs)
provider: ProviderKind::Newprovider,  // unknown to the checker's map
// after (crates/config/src/provider.rs)
provider!(
    Anthropic,
    Newprovider,
    "newprovider",
    aliases: [],
);
Defensive patterns

Strategy: validation

Validate before calling

variants = set(re.findall(r'provider:\s*ProviderKind::(\w+)', agent_rs))
unknown = variants - set(variant_to_id)
assert not unknown, sorted(unknown)

Prevention

When it happens

Trigger: Adding a ModelRegistry entry for a provider before registering it in provider.rs; a typo in the variant name in agent.rs; renaming a ProviderKind variant in config without updating agent; implementing the provider in a way provider_kind_ids() does not recognize.

Common situations: Cross-crate provider onboarding done in the wrong order; rename refactors that miss crates/agent.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@8880682c63 (2026-08-16). Data as JSON: /api/errors/28c5224c8c9013b4. Report an issue: GitHub.