Hmbown/CodeWhale · error · ValueError
{context}: missing {needle!r}
Error message
{context}: missing {needle!r} What it means
require_index in scripts/check-provider-registry.py could not find a required literal substring (the needle) in the file named by the context. The checker navigates the Rust sources and docs/PROVIDERS.md by exact string anchors — struct declarations, impl blocks, the parse signature, Markdown headings — so this fires whenever an anchor is renamed, moved, or deleted out from under the script. The message names both the file and the exact missing literal.
Source
Thrown at scripts/check-provider-registry.py:76
def display_public_value(value: str) -> str:
if SENSITIVE_IDENTIFIER_RE.search(value):
return "<redacted sensitive identifier>"
return value
def redact_sensitive_text(value: str) -> str:
value = SENSITIVE_BEARER_RE.sub(r"\1<redacted>", value)
value = SENSITIVE_ASSIGNMENT_RE.sub(r"\1\2<redacted>", value)
return SENSITIVE_IDENTIFIER_RE.sub("<redacted sensitive identifier>", value)
def require_index(source: str, needle: str, context: str, start: int = 0) -> int:
try:
return source.index(needle, start)
except ValueError:
raise ValueError(f"{context}: missing {needle!r}") from None
def markdown_section(source: str, heading: str) -> str:
start = require_index(source, heading, "docs/PROVIDERS.md")
next_heading = source.find("\n## ", start + len(heading))
end = len(source) if next_heading == -1 else next_heading
return source[start:end]
def extract_match_block(
source: str, signature: str, context: str, start: int = 0
) -> str:
start = require_index(source, signature, context, start)
match_start = require_index(source, "match", f"match block after {signature!r}", start)
brace_start = require_index(source, "{", f"match block after {signature!r}", match_start)
depth = 0
for index in range(brace_start, len(source)):
char = source[index]View on GitHub (pinned to 8880682c63)
Solutions
- Grep the file named in the message for the quoted needle to see how the anchor now reads
- Restore the anchor (exact heading text, signature, or declaration) if the change was cosmetic
- If the code legitimately moved, update the corresponding path constant at the top of scripts/check-provider-registry.py (PROVIDER_KIND_RS, TUI_CONFIG_MODELS_RS, ...) as done for earlier module splits
- Run the script locally before pushing refactors that touch provider files
Example fix
// before (docs/PROVIDERS.md) ## Providers We Ship // after — restore the exact anchor the script searches for ## Shipped Providers
Defensive patterns
Strategy: try-catch
Validate before calling
anchors = ['pub struct ProvidersToml', '## Shipped Providers', '## Static Model Registry']
for a in anchors:
assert a in source, f'anchor drifted: {a}' Try / catch
try:
run_check()
except ValueError as e:
fail_with_context(str(e)) # message already names the file and needle Prevention
- Keep provider anchors (struct/impl/parse signature, Markdown headings) textually stable
- Update path constants in check-provider-registry.py when modules move
- Run scripts/check-provider-registry.py locally before pushing refactors
When it happens
Trigger: Renaming `pub struct ProvidersToml`, `impl ProviderKind`, or `pub fn parse(value: &str) -> Option<Self>`; retitling the `## Shipped Providers` or `## Static Model Registry` heading in docs/PROVIDERS.md; moving code into a module the script does not read (as with the historical splits into provider_kind.rs and config/models.rs).
Common situations: Refactors that relocate provider code; documentation reorganizations; formatting changes that alter an anchor's exact text.
Related errors
- no default provider model/base URL constants found
- could not parse match block after {signature!r}
- {context}: missing parse arm for {variant}
- provider!() invocations returned no providers
- ProvidersToml returned no provider tables
AI-assisted analysis of Hmbown/CodeWhale@8880682c63 (2026-08-16).
Data as JSON: /api/errors/bfe7537e389ed2a3.
Report an issue: GitHub.