{"record":{"id":"1fb722c8411df4e7","repo":"Hmbown/CodeWhale","slug":"providerstoml-returned-no-provider-tables","errorCode":null,"errorMessage":"ProvidersToml returned no provider tables","messagePattern":"ProvidersToml returned no provider tables","errorType":"console","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"scripts/check-provider-registry.py","lineNumber":246,"sourceCode":"    variant_to_id = provider_kind_ids(\"\")\n    # ApiProvider::SiliconflowCn maps to ProviderKind::SiliconflowCN\n    if \"SiliconflowCN\" in variant_to_id:\n        variant_to_id[\"SiliconflowCn\"] = variant_to_id[\"SiliconflowCN\"]\n    variant_to_id[\"DeepseekCN\"] = \"deepseek-cn\"\n    return variant_to_id\n\n\ndef provider_tables(config_rs: str) -> set[str]:\n    struct_start = require_index(\n        config_rs, \"pub struct ProvidersToml\", \"crates/config/src/lib.rs\"\n    )\n    struct_end = require_index(config_rs, \"\\n}\", \"ProvidersToml struct\", struct_start)\n    fields = re.findall(\n        r\"pub\\s+([a-z0-9_]+)\\s*:\\s*ProviderConfigToml\",\n        config_rs[struct_start:struct_end],\n    )\n    if not fields:\n        raise ValueError(\"ProvidersToml returned no provider tables\")\n    return set(fields)\n\n\ndef shipped_provider_rows(providers_md: str) -> set[str]:\n    table = markdown_section(providers_md, \"## Shipped Providers\")\n    return set(re.findall(r\"^\\|\\s*`([^`]+)`\\s*\\|\", table, flags=re.MULTILINE))\n\n\ndef shipped_provider_tables(providers_md: str) -> set[str]:\n    table = markdown_section(providers_md, \"## Shipped Providers\")\n    return set(re.findall(r\"\\|\\s*`\\[providers\\.([a-z0-9_]+)\\]`\\s*\\|\", table))\n\n\ndef documented_selectable_provider_ids(providers_md: str) -> set[str]:\n    marker = require_index(providers_md, \"in that order:\", \"docs/PROVIDERS.md\")\n    start = require_index(providers_md, \"\\n\\n\", \"provider selection list\", marker) + 2\n    end = require_index(providers_md, \"\\n\\n\", \"provider selection list\", start)\n    return set(re.findall(r\"`([^`]+)`\", providers_md[start:end]))","sourceCodeStart":228,"sourceCodeEnd":264,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/scripts/check-provider-registry.py#L228-L264","documentation":"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.","triggerScenarios":"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).","commonSituations":"A refactor wraps provider tables in Option<ProviderConfigToml> or moves ProvidersToml out of lib.rs; a type rename from ProviderConfigToml to something else.","solutions":["Check the ProvidersToml struct in crates/config/src/lib.rs: fields must be declared as `pub name: ProviderConfigToml`.","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).","If ProvidersToml moved files, update CONFIG_RS at the top of the script."],"exampleFix":"// before\npub struct ProvidersToml {\n    pub openai: Option<ProviderConfigToml>,\n}\n// after\npub struct ProvidersToml {\n    pub openai: ProviderConfigToml,\n}","handlingStrategy":"validation","validationCode":"import re\nsrc = open(\"crates/config/src/lib.rs\").read()\nm = re.search(r\"struct ProvidersToml.*?\\n\\}\", src, re.DOTALL)\nfields = re.findall(r\"pub\\s+([a-z0-9_]+)\\s*:\\s*ProviderConfigToml\", m.group(0))\nassert fields, \"ProvidersToml has no ProviderConfigToml fields\"","typeGuard":"def providers_toml_has_fields(config_rs: str) -> bool:\n    m = re.search(r\"struct ProvidersToml[\\s\\S]*?\\n\\}\", config_rs)\n    return bool(m and re.findall(r\"pub\\s+[a-z0-9_]+\\s*:\\s*ProviderConfigToml\", m.group(0)))","tryCatchPattern":"try:\n    tables = provider_tables(read(CONFIG_RS))\nexcept ValueError as e:\n    print(f\"check aborted: {e}\"); sys.exit(1)","preventionTips":["Keep ProvidersToml fields typed as ProviderConfigToml; wrap optionality inside that type, not at the field.","If moving the struct, update CONFIG_RS in the check script in the same commit.","Run the drift check before restructuring config code."],"tags":["python","regex-parse","rust","config"],"backgroundTag":"internal-invariant-violation","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"}