Hmbown/CodeWhale · error · ValueError
: missing
Error message
{context}: missing {needle!r} What it means
require_index() is the lookup helper for the provider-registry consistency guard; it wraps str.index and converts a failed substring search into a descriptive ValueError naming the context and the missing needle. Nearly every textual assertion in scripts/check-provider-registry.py funnels through it, so this error means the guard expected some marker (heading, code snippet, table row) in the sources it reads and did not find it.
Solutions
- Re-add or restore the missing marker the guard expects (heading, snippet, or table entry) in the indicated context
- Update the guard's expected needle strings if the source format legitimately changed (and update both sides consistently)
- Regenerate or re-sync docs/PROVIDERS.md from the current provider registry
Example fix
// before: docs/PROVIDERS.md missing the '## Selecting a provider' heading // after: re-add '## Selecting a provider' section with the required provider table
Defensive patterns
Strategy: validation
Validate before calling
for needle in required_markers:
if needle not in docs_source:
print(f"docs/PROVIDERS.md missing {needle!r}") Try / catch
try:
section = markdown_section(source, "## Selecting a provider")
except ValueError as e:
print(f"doc structure changed: {e}", file=sys.stderr)
sys.exit(1) Prevention
- Keep required doc headings stable; treat them as contract
- Re-sync docs/PROVIDERS.md whenever providers are added/renamed
- Run the guard locally before committing doc edits
When it happens
Trigger: Running scripts/check-provider-registry.py when any searched text — a docs/PROVIDERS.md heading, a code pattern in config source, an alias table entry, a selector contract marker — is absent from the file being scanned, or the optional start offset skips past it.
Common situations: A provider was renamed or removed from docs or code without updating the other side; a doc heading was reworded; the expected Rust snippet format changed after a refactor; editing docs/PROVIDERS.md and dropping a required section.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- : missing parse arm for
- expected a hand-written `impl Provider for
- provider!() invocations returned no providers
- baseline receipt does not match baseline_observation
- baseline receipt does not match baseline provenance
AI-assisted analysis of Hmbown/CodeWhale@433685b202 (2026-09-15).
Data as JSON: /api/errors/bfe7537e389ed2a3.
Report an issue: GitHub.
Appendix: source
Thrown at scripts/check-provider-registry.py:87
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 433685b202)