Skip to content

Add ReadConfig with an option to skip invalid entries - #102

Open
emschwartz wants to merge 1 commit into
rust-syndication:masterfrom
emschwartz:skip-invalid-entries
Open

emschwartz wants to merge 1 commit into
rust-syndication:masterfrom
emschwartz:skip-invalid-entries

Conversation

@emschwartz

Copy link
Copy Markdown
Contributor

Refs #100. Adds the per-entry skipping @andy128k suggested in #100 (comment), following the idea from their rust-syndication/rss#69: keep the rest of the feed when one item is broken. Unlike rss#69, which was about malformed XML, this only skips entries with invalid values; malformed XML stays fatal.

let xml = r#"<feed xmlns="http://www.w3.org/2005/Atom">
  <entry><id>good</id><updated>2024-01-02T00:00:00Z</updated></entry>
  <entry><id>bad</id><updated>Tuesday, January 2nd</updated></entry>
</feed>"#;

Feed::read_from(xml.as_bytes());
// Err(WrongDatetime("Tuesday, January 2nd")), unchanged

let mut config = ReadConfig::default();
config.skip_invalid_entries = true;
Feed::read_with_config(xml.as_bytes(), config)?.entries.len();
// 1

The default stays strict, so validators built on the crate still see the error. Only WrongDatetime and WrongAttribute are skipped; malformed XML still fails the feed. After a failed entry the reader skips to its matching </entry> with the same skip helper used elsewhere, which works wherever inside the entry the error came from (e.g. a bad date in <source>).

ReadConfig is #[non_exhaustive], unlike WriteConfig, so the relaxed-validation option from the issue (treat a bad date as missing) can be added later as a second field without a breaking change. That option is left out of this PR.

#100 is assigned to @DCjanus; if there is already work in progress there, feel free to close this.

Authored by Claude (claude-opus-5-5)

@codecov

codecov Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.66667% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 84.68%. Comparing base (01f0a77) to head (274239c).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
src/feed.rs 91.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #102      +/-   ##
==========================================
+ Coverage   83.85%   84.68%   +0.82%     
==========================================
  Files          14       14              
  Lines        1016     1038      +22     
==========================================
+ Hits          852      879      +27     
+ Misses        164      159       -5     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread src/feed.rs Resolved
One entry with an unparseable date or an unknown text type made
Feed::read_from fail, losing every other entry in the feed. With
ReadConfig::skip_invalid_entries set, Feed::read_with_config leaves
such an entry out and keeps reading. The default stays strict so the
crate can still be used to validate feeds, and malformed XML is
still an error.

andy128k suggested skipping invalid entries in
rust-syndication#100 (comment),
following their earlier proposal in
rust-syndication/rss#69 to keep the rest of
a feed when one item is broken. That proposal was about malformed
XML; this only covers entries with invalid values.

Review fix from andy128k: ReadConfig no longer derives Copy, so
non-Copy options can be added later without a breaking change
(rust-syndication#102 (comment)).

Refs rust-syndication#100

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants