Repository navigation
feat(fetcher/news): add news_* family with 93 curated sources / 20 sub-genres - #218
Conversation
Adds a `news_*` fetcher family, registering one fetcher per entry in a static `NewsSource` table. Each source hardcodes its feed URL set, so the family is `Safety::Safe` (no trust-gate friction, drop-in usable in a fresh install) and config can pick among a closed enum of sub-feeds via `feed = "<key>"` without the ability to inject new destinations. The first batch covers 39 sources / 65 feeds across 14 sub-genres: general, tech, gadget, business, science, security, linux, gaming, ai, hardware, web, apple, android, space, climate. Six sources (BBC, Guardian, ArsTechnica, TechCrunch, Verge, WIRED) expose multiple sub-feeds; the rest expose a single default feed. Adding more sources = appending one `NewsSource` row to `sources.rs`; registration in `mod.rs` is automatic. The shared HTTP fetch + feed-rs parse + entry-to-row formatting pipeline moves from `rss.rs` into `src/fetcher/feed.rs` so both `rss` (generic Network feed) and `news_*` (curated Safe feeds) reuse it. `rss` behaviour and test surface are unchanged. Live smoke test (`#[ignore]`) hits every bundled feed in parallel and asserts at least one entry parses, so future feed-URL rot surfaces via `cargo test -- --ignored fetcher::news::tests::live_every_bundled_feed_parses`. Ticks the news_* checkboxes on #67. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #218 +/- ##
==========================================
- Coverage 95.59% 95.46% -0.14%
==========================================
Files 156 159 +3
Lines 46971 47253 +282
==========================================
+ Hits 44903 45111 +208
- Misses 2068 2142 +74
🚀 New features to boost your workflow:
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughExtracts a shared feed pipeline (HTTP client, capped fetching, parsing, rendering, thumbnail extraction), adds a curated ChangesFeed Pipeline and News Fetcher Family
Estimated Code Review Effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related issues
Possibly related PRs
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 docstrings
🧪 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: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/fetcher/feed.rs (1)
1-260: 🛠️ Refactor suggestion | 🟠 Major | 🏗️ Heavy liftMove feed helper tests into
src/fetcher/feed.rsunder#[cfg(test)].This module now owns parsing/formatting logic, but the corresponding helper tests are housed in
src/fetcher/rss.rs. Please colocate unit tests with this module and keep cross-module/live behavior tests separate.As per coding guidelines, "Tests must live next to the code in
#[cfg(test)] mod testsblocks; integration and cross-module tests reusesrc/render/test_utils.rs."🤖 Prompt for 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. In `@src/fetcher/feed.rs` around lines 1 - 260, Move the unit tests that exercise this module's parsing/formatting helpers out of src/fetcher/rss.rs and into src/fetcher/feed.rs in a #[cfg(test)] mod tests block so the tests live next to the code they cover; specifically add tests for functions like thumbnail_url_for, first_inline_image_src, title_or_placeholder, collapse_whitespace, date_label/format_short, line_text, subtitle_for and link_for inside that tests module, import any needed test utilities from src/render/test_utils.rs for cross-module fixtures, and remove or adjust the now-duplicated helper tests in rss.rs so only integration/cross-module tests remain there.
🤖 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 `@src/fetcher/feed.rs`:
- Around line 54-73: The current implementation in fetcher/feed.rs calls
res.bytes().await (see res.bytes().await and MAX_BYTES) which buffers the whole
body before checking size; change to read the response as a stream (e.g., using
res.bytes_stream() or an async loop over res.chunk()/Stream of Bytes) and
accumulate into a Vec<u8> while checking the running total against MAX_BYTES on
each chunk, returning FetchError::Failed with the same message when the cap is
exceeded; keep the same error mapping for network/read failures (where you
previously used map_err to create FetchError::Failed) and preserve the status
check logic around res.status() and the existing label text.
In `@src/fetcher/news/sources.rs`:
- Around line 94-120: Replace insecure http BBC feed URLs with https in the
NewsFeed definitions in src/fetcher/news/sources.rs so the curated sources use
TLS; update the url fields for the NewsFeed instances with keys "world", "top",
"business", "tech", "science", and "politics" to start with "https://" instead
of "http://", keeping the rest of each URL and labels unchanged.
---
Outside diff comments:
In `@src/fetcher/feed.rs`:
- Around line 1-260: Move the unit tests that exercise this module's
parsing/formatting helpers out of src/fetcher/rss.rs and into
src/fetcher/feed.rs in a #[cfg(test)] mod tests block so the tests live next to
the code they cover; specifically add tests for functions like
thumbnail_url_for, first_inline_image_src, title_or_placeholder,
collapse_whitespace, date_label/format_short, line_text, subtitle_for and
link_for inside that tests module, import any needed test utilities from
src/render/test_utils.rs for cross-module fixtures, and remove or adjust the
now-duplicated helper tests in rss.rs so only integration/cross-module tests
remain there.
🪄 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: defaults
Review profile: CHILL
Plan: Pro
Run ID: a38a4087-5872-4b88-a661-a42109689d18
📒 Files selected for processing (5)
src/fetcher/feed.rssrc/fetcher/mod.rssrc/fetcher/news/mod.rssrc/fetcher/news/sources.rssrc/fetcher/rss.rs
| let res = http() | ||
| .get(url.as_str()) | ||
| .send() | ||
| .await | ||
| .map_err(|e| FetchError::Failed(format!("{label} request failed: {e}")))?; | ||
| let status = res.status(); | ||
| if !status.is_success() { | ||
| return Err(FetchError::Failed(format!("{label} {status}"))); | ||
| } | ||
| let bytes = res | ||
| .bytes() | ||
| .await | ||
| .map_err(|e| FetchError::Failed(format!("{label} read body: {e}")))?; | ||
| if bytes.len() > MAX_BYTES { | ||
| return Err(FetchError::Failed(format!( | ||
| "{label} response too large ({} bytes, cap {MAX_BYTES})", | ||
| bytes.len() | ||
| ))); | ||
| } | ||
| Ok(bytes.to_vec()) |
There was a problem hiding this comment.
🧩 Analysis chain
🌐 Web query:
In reqwest 0.12, does Response::bytes() buffer the entire response body in memory before returning?
💡 Result:
Yes. In reqwest 0.12, Response::bytes buffers/collects the entire response body into memory before returning. Evidence: reqwest’s async Response::bytes implementation calls http_body_util::BodyExt::collect(...) on the response body and then converts the collected buffer into Bytes, which implies the whole body is aggregated before the method completes [1]. The docs for Response::bytes describe it as “Get the full response body as Bytes” [2]. Additionally, http_body_util::BodyExt::collect is defined as collecting “all the DATA frames and trailers,” which is the mechanism reqwest uses under the hood [3]. If you want streaming instead of full buffering, reqwest provides Response::bytes_stream, which returns a Stream of Bytes rather than a fully collected Bytes buffer [2].
Citations:
- 1: https://github.com/seanmonstar/reqwest/blob/master/src/async_impl/response.rs
- 2: https://docs.rs/reqwest/latest/reqwest/struct.Response.html
- 3: https://docs.rs/http-body-util/latest/http_body_util/trait.BodyExt.html
🏁 Script executed:
head -80 src/fetcher/feed.rs | tail -35Repository: unhappychoice/splashboard
Length of output: 1169
🏁 Script executed:
rg "MAX_BYTES" src/fetcher/Repository: unhappychoice/splashboard
Length of output: 1778
🏁 Script executed:
rg "#\[cfg\(test\)\]" src/fetcher/feed.rsRepository: unhappychoice/splashboard
Length of output: 51
🏁 Script executed:
rg "feed::MAX_BYTES" src/fetcher/rss.rs -A 2 -B 2Repository: unhappychoice/splashboard
Length of output: 341
🏁 Script executed:
grep -n "#\[cfg(test)\]" src/fetcher/rss.rs | head -5Repository: unhappychoice/splashboard
Length of output: 86
🏁 Script executed:
wc -l src/fetcher/feed.rsRepository: unhappychoice/splashboard
Length of output: 93
🏁 Script executed:
rg "chunk\(\)" src/fetcher/ -A 2 -B 2Repository: unhappychoice/splashboard
Length of output: 51
🏁 Script executed:
rg "streaming\|bytes_stream\|chunk" src/fetcher/ -cRepository: unhappychoice/splashboard
Length of output: 51
🏁 Script executed:
cat -n src/fetcher/feed.rs | sed -n '40,80p'Repository: unhappychoice/splashboard
Length of output: 1633
🏁 Script executed:
rg "fn fetch_bytes" src/fetcher/ -A 25Repository: unhappychoice/splashboard
Length of output: 16064
Enforce MAX_BYTES while streaming, not after full buffering.
Line 64 (res.bytes().await) buffers the entire response before line 67 checks size, so oversized feeds can still consume up to the cap in memory.
Suggested patch
- let res = http()
+ let mut res = http()
.get(url.as_str())
.send()
.await
.map_err(|e| FetchError::Failed(format!("{label} request failed: {e}")))?;
let status = res.status();
@@
- let bytes = res
- .bytes()
- .await
- .map_err(|e| FetchError::Failed(format!("{label} read body: {e}")))?;
- if bytes.len() > MAX_BYTES {
- return Err(FetchError::Failed(format!(
- "{label} response too large ({} bytes, cap {MAX_BYTES})",
- bytes.len()
- )));
- }
- Ok(bytes.to_vec())
+ if let Some(len) = res.content_length() {
+ if len as usize > MAX_BYTES {
+ return Err(FetchError::Failed(format!(
+ "{label} response too large ({len} bytes, cap {MAX_BYTES})"
+ )));
+ }
+ }
+ let mut out = Vec::new();
+ while let Some(chunk) = res
+ .chunk()
+ .await
+ .map_err(|e| FetchError::Failed(format!("{label} read body: {e}")))?
+ {
+ if out.len() + chunk.len() > MAX_BYTES {
+ return Err(FetchError::Failed(format!(
+ "{label} response too large (>{MAX_BYTES} bytes)"
+ )));
+ }
+ out.extend_from_slice(&chunk);
+ }
+ Ok(out)📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| let res = http() | |
| .get(url.as_str()) | |
| .send() | |
| .await | |
| .map_err(|e| FetchError::Failed(format!("{label} request failed: {e}")))?; | |
| let status = res.status(); | |
| if !status.is_success() { | |
| return Err(FetchError::Failed(format!("{label} {status}"))); | |
| } | |
| let bytes = res | |
| .bytes() | |
| .await | |
| .map_err(|e| FetchError::Failed(format!("{label} read body: {e}")))?; | |
| if bytes.len() > MAX_BYTES { | |
| return Err(FetchError::Failed(format!( | |
| "{label} response too large ({} bytes, cap {MAX_BYTES})", | |
| bytes.len() | |
| ))); | |
| } | |
| Ok(bytes.to_vec()) | |
| let mut res = http() | |
| .get(url.as_str()) | |
| .send() | |
| .await | |
| .map_err(|e| FetchError::Failed(format!("{label} request failed: {e}")))?; | |
| let status = res.status(); | |
| if !status.is_success() { | |
| return Err(FetchError::Failed(format!("{label} {status}"))); | |
| } | |
| if let Some(len) = res.content_length() { | |
| if len as usize > MAX_BYTES { | |
| return Err(FetchError::Failed(format!( | |
| "{label} response too large ({len} bytes, cap {MAX_BYTES})" | |
| ))); | |
| } | |
| } | |
| let mut out = Vec::new(); | |
| while let Some(chunk) = res | |
| .chunk() | |
| .await | |
| .map_err(|e| FetchError::Failed(format!("{label} read body: {e}")))? | |
| { | |
| if out.len() + chunk.len() > MAX_BYTES { | |
| return Err(FetchError::Failed(format!( | |
| "{label} response too large (>{MAX_BYTES} bytes)" | |
| ))); | |
| } | |
| out.extend_from_slice(&chunk); | |
| } | |
| Ok(out) |
🤖 Prompt for 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.
In `@src/fetcher/feed.rs` around lines 54 - 73, The current implementation in
fetcher/feed.rs calls res.bytes().await (see res.bytes().await and MAX_BYTES)
which buffers the whole body before checking size; change to read the response
as a stream (e.g., using res.bytes_stream() or an async loop over
res.chunk()/Stream of Bytes) and accumulate into a Vec<u8> while checking the
running total against MAX_BYTES on each chunk, returning FetchError::Failed with
the same message when the cap is exceeded; keep the same error mapping for
network/read failures (where you previously used map_err to create
FetchError::Failed) and preserve the status check logic around res.status() and
the existing label text.
Second batch — 53 sources across existing categories + 5 new sub-genres. Existing categories filled out (+39): - general (france24, dw, sky_news, cbs) - tech (the_register, zdnet, slashdot, venturebeat) - gadget (techradar) - business (forbes, economist, fortune) - science (new_scientist, sciencedaily, phys_org) - security (the_hacker_news, threatpost, dark_reading, graham_cluley) - linux (its_foss, distrowatch) - gaming (kotaku, ign, pc_gamer, vg247) - ai (hugging_face_blog, the_gradient, mit_tr_ai) - hardware (techpowerup, ifixit) - web (a_list_apart, ux_collective) - apple (daring_fireball, appleinsider) - android (android_authority, xda) - space (nasa_news, space_com) - climate (carbon_brief) New sub-genres (+14): - politics (politico, propublica, vox) - photography (dpreview, petapixel, fstoppers) - entertainment (variety, deadline, indiewire) - music (pitchfork, stereogum) - crypto (coindesk, the_block, decrypt) Sophos Naked Security shut down in 2024 and gets replaced by graham_cluley (former Sophos blogger, same niche). sidebar.io and designernews.co are both returning connection failures and get replaced by ux_collective. All 120 feed URLs (93 sources × sub-feeds) verified live with `live_every_bundled_feed_parses`; smallest is news_quanta_magazine at 5 entries, largest news_hugging_face_blog at 777. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…test Eight feeds (six BBC sub-feeds + slashdot + distrowatch) were copied verbatim from the catalog issue's older URLs and were still on plaintext http://. All of them serve the same RSS over https with a 200 — no functional change, just loss-prevention if a proxy / corporate firewall strips http. Tightens `all_sources_are_news_prefixed_and_have_at_least_one_feed` to require `https://` so a future row added with http:// fails CI. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/fetcher/news/sources.rs (1)
94-1291: 🏗️ Heavy liftSplit the
SOURCEScatalog into smaller per-category modules.This file is now very large, which will make curation changes harder to review and maintain. Consider moving category slices into separate files and composing
SOURCESfrom them.As per coding guidelines, "Keep files small, aiming for ~100 lines where practical".
🤖 Prompt for 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. In `@src/fetcher/news/sources.rs` around lines 94 - 1291, The SOURCES constant has grown too large; split it into smaller modules by category and recompose the master list. Create separate files (e.g., modules) that each export a slice/array of NewsSource for a single NewsCategory (using the NewsSource/NewsFeed structs and the NewsCategory enum), move corresponding entries from SOURCES into those per-category exports, then update this file to import and concatenate those slices into the single pub const SOURCES: &[NewsSource] (or build a lazy/static combined vector if const composition isn't possible) so maintenance and reviews are per-category.
🤖 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 `@src/fetcher/news/sources.rs`:
- Around line 757-764: Update the feed URL strings to use HTTPS instead of HTTP
for the affected NewsFeed entries: locate the NewsFeed in the "news_slashdot"
declaration (key "main", url "http://rss.slashdot.org/Slashdot/slashdotMain")
and change it to "https://rss.slashdot.org/Slashdot/slashdotMain"; likewise
locate the DistroWatch NewsFeed declaration (the entry referenced around the
"news_distrowatch" symbol) and change its url from "http://..." to
"https://...". Ensure only the URL schemes are changed and no other fields are
modified so feeds continue to function identically but over HTTPS.
---
Nitpick comments:
In `@src/fetcher/news/sources.rs`:
- Around line 94-1291: The SOURCES constant has grown too large; split it into
smaller modules by category and recompose the master list. Create separate files
(e.g., modules) that each export a slice/array of NewsSource for a single
NewsCategory (using the NewsSource/NewsFeed structs and the NewsCategory enum),
move corresponding entries from SOURCES into those per-category exports, then
update this file to import and concatenate those slices into the single pub
const SOURCES: &[NewsSource] (or build a lazy/static combined vector if const
composition isn't possible) so maintenance and reviews are per-category.
🪄 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: defaults
Review profile: CHILL
Plan: Pro
Run ID: 9be98be3-6ddd-4b74-8e2d-7c279b40b870
📒 Files selected for processing (1)
src/fetcher/news/sources.rs
feat(fetcher/news): add news_bloomberg + news_wsj (correction to #218)
Summary
Adds a
news_*fetcher family. Each entry in a staticNewsSourcetable registers as a separatenews_<slug>fetcher with a hardcoded feed URL set, so the family isSafety::Safe(no trust-gate friction, drop-in usable in a fresh install) and config can pick among a closed enum of sub-feeds viafeed = "<key>"without injecting new destinations.93 sources / 120 feeds / 20 sub-genres:
Six sources (BBC, Guardian, ArsTechnica, TechCrunch, Verge, WIRED) expose multiple sub-feeds; the rest expose a single default feed. Adding more sources = appending one row to
sources.rs; registration inmod.rsis automatic.Refactors
rss's HTTP + feed-rs + entry-to-row pipeline into a sharedsrc/fetcher/feed.rssorss(generic Network feed) andnews_*(curated Safe feeds) reuse it.rssbehaviour and test surface unchanged.Live verification
#[ignore]-d test hits every bundled feed in parallel and asserts at least one entry parses; surfaces feed-URL rot via:Confirmed locally — all 120 feeds returned ≥5 entries (smallest: Quanta Magazine with 5; largest: Hugging Face Blog with 777).
Source choices worth flagging
github_blog/cloudflare_blog-style product PR.Auto-generated reference (preview of
/reference/fetchers/news/news_bbc/)linked_text_block,image_linked_list,text_blockOptions
feed"world"/"tech"). Runsplashboard catalog fetcher news_<source>to list available keys.countCompatible renderers
linked_text_blocklist_linksimage_linked_listlist_cardstext_blockanimated_boot,animated_postfx,animated_scanlines,animated_splitflap,animated_wave,list_plainTest plan
cargo fmt --all -- --checkcargo clippy --all-targets -- -D warningscargo test(2126 tests pass, including 13 news tests + 41 unchanged rss tests)cargo test -- --ignored fetcher::news::tests::live_every_bundled_feed_parses(all 120 feeds parse ≥5 entries each)cargo run --bin splashboardwith a per-dir.splashboard/dashboard.tomlexercising default sub-feed, explicit sub-feed,TextBlock/list_plain, andImageLinkedList/list_cardspathsTicks the corresponding
news_*checkboxes on #67.🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Refactor
Tests