Hmbown/CodeWhale · error · ValueError
crates/config/src/provider_kind.rs: missing…
Error message
crates/config/src/provider_kind.rs: missing ProviderKind::ALL
What it means
check-provider-registry.py parses crates/config/src/provider_kind.rs with a regex expecting a `pub const ALL: [Self; N] = [Self::A, Self::B, ...];` array. If the regex finds no match it raises this ValueError, so the docs/registry consistency check cannot proceed. It fires when ProviderKind::ALL was renamed, reformatted, moved to another file, or typed in a way the regex does not recognize.
Solutions
- Open crates/config/src/provider_kind.rs and confirm a `pub const ALL: [ProviderKind; N]` (written as `[Self; N]`) array exists; restore or add it if the refactor removed or renamed it.
- If ALL was intentionally changed to another shape (slice, function), update the regex in scripts/check-provider-registry.py:216 (provider_kind_catalog_ids) to match the new declaration.
- If the constant moved to another file, update PROVIDER_KIND_RS at the top of the script to point at the new path.
Example fix
// before pub const ALL: &[ProviderKind] = &[Self::Anthropic, Self::OpenAI]; // after pub const ALL: [Self; 2] = [Self::Anthropic, Self::OpenAI];
Defensive patterns
Strategy: validation
Validate before calling
import re
src = open("crates/config/src/provider_kind.rs").read()
assert re.search(r"pub const ALL:\s*\[Self;\s*\d+\]\s*=\s*\[(.*?)\];", src, re.DOTALL), "ProviderKind::ALL missing or in unexpected form" Type guard
def has_all_catalog(src: str) -> bool:
return re.search(r"pub const ALL:\s*\[Self;\s*\d+\]\s*=\s*\[(.*?)\];", src, re.DOTALL) is not None Try / catch
try:
ids = provider_kind_catalog_ids(read(PROVIDER_KIND_RS))
except ValueError as e:
print(f"check skipped: {e}"); sys.exit(1) Prevention
- Keep ProviderKind::ALL declared exactly as `pub const ALL: [Self; N] = [...]` and note the constraint in a comment near it.
- Run the registry check script locally before committing enum changes.
- When changing ALL's type, grep scripts/ for its consumers in the same commit.
When it happens
Trigger: Running the script when provider_kind.rs has no `pub const ALL: [Self; <int>] = [...];` declaration matching the regex `pub const ALL:\s*\[Self;\s*\d+\]\s*=\s*\[(.*?)\];` — e.g. the constant was renamed, changed to a slice/Vec, split across lines with an unexpected type, or the file was moved from crates/config/src/provider_kind.rs.
Common situations: A refactor changed ALL from a fixed-size array to `&[ProviderKind]` or a function; the module split (lib.rs -> provider_kind.rs) was done but ALL still lives in lib.rs; a formatter or hand edit changed whitespace/type spelling so the regex no longer matches.
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
- no default provider model/base URL constants found
- ProvidersToml returned no provider tables
- : missing parse arm for
- could not parse match block after
- expected a hand-written `impl Provider for
AI-assisted analysis of Hmbown/CodeWhale@433685b202 (2026-09-15).
Data as JSON: /api/errors/1eac75975d3db89e.
Report an issue: GitHub.
Appendix: source
Thrown at scripts/check-provider-registry.py:216
raise ValueError(
f"expected a hand-written `impl Provider for {variant_name}` "
f"with id {id_literal!r}; the guard's floor is stale"
)
if not ids:
raise ValueError("provider!() invocations returned no providers")
return ids
def provider_kind_catalog_ids(
provider_kind_rs: str, variant_to_id: dict[str, str]
) -> set[str]:
catalog = re.search(
r"pub const ALL:\s*\[Self;\s*\d+\]\s*=\s*\[(.*?)\];",
provider_kind_rs,
flags=re.DOTALL,
)
if catalog is None:
raise ValueError("crates/config/src/provider_kind.rs: missing ProviderKind::ALL")
variants = set(re.findall(r"Self::(\w+)", catalog.group(1)))
catalog_variant_to_id = {**variant_to_id, "Custom": "custom"}
missing = variants - set(catalog_variant_to_id)
if missing:
raise ValueError(f"ProviderKind::ALL uses unknown variants: {sorted(missing)}")
return {catalog_variant_to_id[variant] for variant in variants}
def api_provider_ids(tui_config_rs: str) -> dict[str, str]:
# ApiProvider ids derive from ProviderKind ids (via delegation to .kind().as_str())
# plus the legacy "deepseek-cn" variant that exists only in ApiProvider.
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
View on GitHub (pinned to 433685b202)