{"record":{"id":"bfe7537e389ed2a3","repo":"Hmbown/CodeWhale","slug":"context-missing-needle-r","errorCode":null,"errorMessage":"{context}: missing {needle!r}","messagePattern":"(.+?): missing (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"scripts/check-provider-registry.py","lineNumber":76,"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":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/8880682c63083a91624de936797efa3ce9e498fd/scripts/check-provider-registry.py#L58-L94","documentation":"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.","triggerScenarios":"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).","commonSituations":"Refactors that relocate provider code; documentation reorganizations; formatting changes that alter an anchor's exact text.","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"],"exampleFix":"// before (docs/PROVIDERS.md)\n## Providers We Ship\n// after — restore the exact anchor the script searches for\n## Shipped Providers","handlingStrategy":"try-catch","validationCode":"anchors = ['pub struct ProvidersToml', '## Shipped Providers', '## Static Model Registry']\nfor a in anchors:\n    assert a in source, f'anchor drifted: {a}'","typeGuard":null,"tryCatchPattern":"try:\n    run_check()\nexcept ValueError as e:\n    fail_with_context(str(e))  # message already names the file and needle","preventionTips":["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"],"tags":["python","static-analysis","docs-drift","refactoring"],"backgroundTag":null,"analyzedSha":"8880682c63083a91624de936797efa3ce9e498fd","analyzedAt":"2026-08-16T11:31:27.956Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}