Repository navigation
fix(commoncrawl): add output=text&fl=url to CDX query so URLs are actually returned - #130
Conversation
…ually returned
The CDX API returns raw CDX-format lines by default (e.g.
`com,example)/ 20260508... {"url":"http://..."}`), but the regex
extractor uses ^ and $ anchors so it only matches when the entire
input line is a URL. Adding `&output=text&fl=url&collapse=urlkey`
makes the API return one plain URL per line (same approach Wayback
Archive already uses with `&output=txt&fl=original`), so the extractor
matches correctly and results are now returned.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
💤 Files with no reviewable changes (1)
Walkthrough
ChangesCommon Crawl API query parameters
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@pkg/source/commoncrawl/commoncrawl.go`:
- Line 124: The code builds currentSearchURL by interpolating rootURL into a
query string which can produce malformed queries if rootURL contains reserved
characters; instead parse searchURL with net/url, create/modify its Query()
(url.Values), set the "url" param to "*."+rootURL (or to a sanitized hostname if
you prefer), set "output"="text", "fl"="url", "collapse"="urlkey", then assign
currentSearchURL = u.String(); update the code around the currentSearchURL
construction (use searchURL, rootURL and the currentSearchURL variable) so
parameters are safely URL-encoded.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 6c79657a-bd0c-45ac-b942-575f595dbce3
📒 Files selected for processing (1)
pkg/source/commoncrawl/commoncrawl.go
…uery params Replace fmt.Sprintf string interpolation with proper URL construction via url.Parse and url.Values.Set so reserved characters in rootURL are safely encoded rather than inserted verbatim into the query string.
Problem
The CommonCrawl source returns no URLs at all.
Root cause: The CDX API returns raw CDX-format lines by default:
But the regex extractor in
pkg/extractor/regex_extractor.gois compiled with^and$anchors, so it only matches when the entire input line is a URL. A CDX record line never matches, so every line silently returns zero results.Fix
Add
&output=text&fl=url&collapse=urlkeyto the CDX query URL, which makes the API return one plain URL per line — the same approach already used by the Wayback Archive source (&output=txt&fl=original).output=text&fl=url— return only the URL field, one per linecollapse=urlkey— deduplicate entries where the same URL was crawled multiple timesTesting
Tested against
example.com— before the fix: 0 results; after: thousands of URLs returned across all subdomains.Summary by CodeRabbit