Hmbown/CodeWhale · error · ValueError

ProvidersToml returned no provider tables

Error message

ProvidersToml returned no provider tables

What it means

The script extracts field names from the ProvidersToml struct in crates/config/src/lib.rs via a regex for `pub <name>: ProviderConfigToml` fields. If no fields match it raises this ValueError, because a ProvidersToml with zero provider tables means the source layout changed or the struct is genuinely empty, and downstream drift checks would silently pass on an empty set.

Solutions

  1. Check the ProvidersToml struct in crates/config/src/lib.rs: fields must be declared as `pub name: ProviderConfigToml`.
  2. If the field type was renamed or wrapped (Option, HashMap), update the regex `pub\s+([a-z0-9_]+)\s*:\s*ProviderConfigToml` in provider_tables (scripts/check-provider-registry.py:~240).
  3. If ProvidersToml moved files, update CONFIG_RS at the top of the script.

Example fix

// before
pub struct ProvidersToml {
    pub openai: Option<ProviderConfigToml>,
}
// after
pub struct ProvidersToml {
    pub openai: ProviderConfigToml,
}
Defensive patterns

Strategy: validation

Validate before calling

import re
src = open("crates/config/src/lib.rs").read()
m = re.search(r"struct ProvidersToml.*?\n\}", src, re.DOTALL)
fields = re.findall(r"pub\s+([a-z0-9_]+)\s*:\s*ProviderConfigToml", m.group(0))
assert fields, "ProvidersToml has no ProviderConfigToml fields"

Type guard

def providers_toml_has_fields(config_rs: str) -> bool:
    m = re.search(r"struct ProvidersToml[\s\S]*?\n\}", config_rs)
    return bool(m and re.findall(r"pub\s+[a-z0-9_]+\s*:\s*ProviderConfigToml", m.group(0)))

Try / catch

try:
    tables = provider_tables(read(CONFIG_RS))
except ValueError as e:
    print(f"check aborted: {e}"); sys.exit(1)

Prevention

When it happens

Trigger: Running the check when the ProvidersToml struct contains no `pub x: ProviderConfigToml` fields — e.g. fields were renamed to another type, the struct moved to another file, or field declarations were restructured (generics, boxed, Option-wrapped).

Common situations: A refactor wraps provider tables in Option<ProviderConfigToml> or moves ProvidersToml out of lib.rs; a type rename from ProviderConfigToml to something else.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@433685b202 (2026-09-15). Data as JSON: /api/errors/1fb722c8411df4e7. Report an issue: GitHub.

Appendix: source

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

    variant_to_id = provider_kind_ids("")
    # ApiProvider::SiliconflowCn maps to ProviderKind::SiliconflowCN
    if "SiliconflowCN" in variant_to_id:
        variant_to_id["SiliconflowCn"] = variant_to_id["SiliconflowCN"]
    variant_to_id["DeepseekCN"] = "deepseek-cn"
    return variant_to_id


def provider_tables(config_rs: str) -> set[str]:
    struct_start = require_index(
        config_rs, "pub struct ProvidersToml", "crates/config/src/lib.rs"
    )
    struct_end = require_index(config_rs, "\n}", "ProvidersToml struct", struct_start)
    fields = re.findall(
        r"pub\s+([a-z0-9_]+)\s*:\s*ProviderConfigToml",
        config_rs[struct_start:struct_end],
    )
    if not fields:
        raise ValueError("ProvidersToml returned no provider tables")
    return set(fields)


def shipped_provider_rows(providers_md: str) -> set[str]:
    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 documented_selectable_provider_ids(providers_md: str) -> set[str]:
    marker = require_index(providers_md, "in that order:", "docs/PROVIDERS.md")
    start = require_index(providers_md, "\n\n", "provider selection list", marker) + 2
    end = require_index(providers_md, "\n\n", "provider selection list", start)
    return set(re.findall(r"`([^`]+)`", providers_md[start:end]))

View on GitHub (pinned to 433685b202)