Repository navigation
fix: surface doc parse failures instead of empty success - #31
Merged
Merged
Conversation
The godoc/rustdoc/pydoc readers discarded the parser's `matched` flag and cached + returned the (possibly empty) document with a nil error. If a site changed its markup so nothing matched, callers got empty output that looked like "no docs" rather than a failure, and the empty result was cached for the 30-minute TTL — poisoning the cache until expiry. Now Read*Paged and SearchWithin* check the parse result and return ErrNotFound when nothing matched (or the document is blank), and only cache non-empty parses. Applied consistently across godoc, rustdoc, and pydoc. This makes pkg.go.dev/docs.rs/docs.python.org markup drift surface as an error instead of silently empty output (golden tests run against saved HTML and cannot catch live drift). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the two robustness gaps found while verifying the dq-based parsers against live pkg.go.dev. The same pattern existed in all three doc readers (godoc, rustdoc, pydoc).
The problems
In
Read*PagedandSearchWithin*:matchedflag was discarded (_, document = parse...). When all parsers missed (e.g. the site renamed a CSS class), the reader returned""with anilerror, indistinguishable from "this package has no docs."docCache.Setran even for an empty document, poisoning the cache for the 30-minute TTL on a transient miss or markup drift.These matter because the parsers are CSS-class-coupled and the golden tests run against saved HTML, so they can't catch live drift — the failure mode was silent empty output.
The fix
Read*Paged/SearchWithin*now check the parse result and returnErrNotFoundwhen nothing matched (or the parsed document is blank), and only cache non-empty parses. Applied consistently acrossgodoc.go,rustdoc.go,pydoc.go(6 call sites).(godoc keeps its
parseDocument→parseReadmefallback; the guard runs after both.)Verification
go build,go vet, fullgo test✅make lint→ 0 issuesparse*directly, not the readers)🤖 Generated with Claude Code