Repository navigation
Mark records read from disallowed pages - #30
Merged
Merged
Conversation
A record built from a page robots.txt asked us not to read now carries a robots block with allowed false, the path, the rule that matched it and which robots.txt said so. A record off an allowed surface carries nothing, so the absence means as much as the presence. Reviews carry it on the row rather than on an envelope, because reviews --all returns the book page's sample and the walked pages in one list and the note is what keeps the two distinguishable after the merge. Also routes the v0.3.0 record fetchers through the client's base URL. They built URLs on the hardcoded BaseURL, so a test that pointed the client at a local server still fetched goodreads.com for real, which is how this was found.
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.
The last unticked line on the v0.3.0 acceptance list in #8:
It was not implemented. A grep for
robots_allowed,RobotsAllowedandrobots.allowedacrossgoodread/andcli/came back empty.What this does
Envelopegains an optionalrobotsblock, and a record built from a pagerobots.txtasked us not to read carries it:allowedis not omitempty, so a consumer readingrobots.allowedgets a false rather than a missing key, andrulequotes the line from the file rather than paraphrasing it.A record off an allowed surface carries nothing, so the absence means as much as the presence, and neither depends on the reader knowing which flags the run used.
The client remembers the verdict on every path the override let through, and each record fetcher stamps what it built. Stamping is a no-op for an allowed page, which is what lets every fetcher call it unconditionally: a surface that becomes disallowed on a later reading of
robots.txtstarts carrying the note with no further code.Reviews carry the block on the row rather than on an envelope. A review is a row and has no envelope, and
reviews --allreturns the book page's sample and the walked pages in one list, so a note on the row is the only thing that keeps them distinguishable after the merge.The bug this turned up
The v0.3.0 record fetchers built URLs with the package helpers, which hardcode
BaseURL. So a test that pointed the client at a local server withSetBaseURLstill fetched goodreads.com for real. The first run of the new test did exactly that and the second one came back with a WAF challenge, which is how it was noticed. They now go throughc.site(), which is a no-op in production becausec.baseisBaseURL.Tests
Three, all against the golden captures rather than fixtures written to pass.
TestDisallowedReadCarriesTheNotewalks/book/reviewsoff the s12 capture and checks every row carries the note with the real rule.TestAllowedReadCarriesNoNotereads the s1 book page with--no-robotson, and checks nothing on the record claims otherwise.TestEveryRecordFetcherStampsparses the package and requires everyGet*Recordmethod to either stamp or be built out of others that did, so a fetcher added later cannot quietly skip it.Docs
The envelope table in the output reference, the
--no-robotssection of the robots guide, and the release notes in bothdocs/and.goreleaser.yaml.Gate:
gofmt -l . && go vet ./... && go test ./...clean.