{"record":{"id":"bfe7537e389ed2a3","repo":"Hmbown/CodeWhale","slug":"context-missing-needle-r","errorCode":null,"errorMessage":"{context}: missing {needle!r}","messagePattern":"(.+?): missing (.+?)","errorType":"console","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"scripts/check-provider-registry.py","lineNumber":87,"sourceCode":"\n\ndef display_public_value(value: str) -> str:\n    if SENSITIVE_IDENTIFIER_RE.search(value):\n        return \"<redacted sensitive identifier>\"\n    return value\n\n\ndef redact_sensitive_text(value: str) -> str:\n    value = SENSITIVE_BEARER_RE.sub(r\"\\1<redacted>\", value)\n    value = SENSITIVE_ASSIGNMENT_RE.sub(r\"\\1\\2<redacted>\", value)\n    return SENSITIVE_IDENTIFIER_RE.sub(\"<redacted sensitive identifier>\", value)\n\n\ndef require_index(source: str, needle: str, context: str, start: int = 0) -> int:\n    try:\n        return source.index(needle, start)\n    except ValueError:\n        raise ValueError(f\"{context}: missing {needle!r}\") from None\n\n\ndef markdown_section(source: str, heading: str) -> str:\n    start = require_index(source, heading, \"docs/PROVIDERS.md\")\n    next_heading = source.find(\"\\n## \", start + len(heading))\n    end = len(source) if next_heading == -1 else next_heading\n    return source[start:end]\n\n\ndef extract_match_block(\n    source: str, signature: str, context: str, start: int = 0\n) -> str:\n    start = require_index(source, signature, context, start)\n    match_start = require_index(source, \"match\", f\"match block after {signature!r}\", start)\n    brace_start = require_index(source, \"{\", f\"match block after {signature!r}\", match_start)\n    depth = 0\n    for index in range(brace_start, len(source)):\n        char = source[index]","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/scripts/check-provider-registry.py#L69-L105","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before: docs/PROVIDERS.md missing the '## Selecting a provider' heading\n// after:  re-add '## Selecting a provider' section with the required provider table","handlingStrategy":"validation","validationCode":"for needle in required_markers:\n    if needle not in docs_source:\n        print(f\"docs/PROVIDERS.md missing {needle!r}\")","typeGuard":null,"tryCatchPattern":"try:\n    section = markdown_section(source, \"## Selecting a provider\")\nexcept ValueError as e:\n    print(f\"doc structure changed: {e}\", file=sys.stderr)\n    sys.exit(1)","preventionTips":["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"],"tags":["python","docs-consistency","provider-registry","ci-guard"],"backgroundTag":"resource-not-found","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"}