Skip to content

Fix invalid dates in feed ordering - #62

Merged
cardmagic merged 1 commit into
masterfrom
fix/invalid-feed-dates
Sep 12, 2026
Merged

cardmagic merged 1 commit into
masterfrom
fix/invalid-feed-dates

Conversation

@cardmagic

@cardmagic cardmagic commented Sep 12, 2026 •

Copy link
Copy Markdown
Owner

A malformed pubDate could make latest raise or hide a valid updated or published timestamp. Use the first valid Time across those fields consistently in latest, items_since, and merge while preserving the original field values.

Sort dated entries newest first, retain source order for ties, and place undated entries after even pre-1970 dates. Preserve merge's identity rules and its placement of unidentified entries at the end. Document the behavior and cover fallback dates, nanosecond precision, stable ordering, deduplication, and unchanged inputs.

Validation: reproduced the mixed String/Time comparison error with a failing regression before the fix. The full suite passes on Ruby 3.4.8 (112 tests, 233 assertions; 3 existing network-test omissions). RuboCop, RBS validation, and Steep pass.

GitHub CI passes on Ruby 3.2, 3.3, 3.4, and 4.0, and Greptile reports 5/5 on e26a025. Hound's style comments were resolved because they conflict with .rubocop.yml: the repository requires double quotes and excludes tests from line-length and method-length checks.

Closes #58.

Use the first valid publication or update timestamp across latest, items_since, and merge. Preserve malformed values and source order for equal or missing dates, including dates before 1970.

Add regression coverage for fallback dates, stable ordering, precision, merge identity rules, and non-mutating results. Document the date selection contract.

Closes #58
Comment thread test/base/date_ordering_test.rb
Comment thread test/base/date_ordering_test.rb
Comment thread test/base/date_ordering_test.rb
Comment thread test/base/date_ordering_test.rb
Comment thread test/base/date_ordering_test.rb
Comment thread test/base/date_ordering_test.rb
Comment thread test/base/date_ordering_test.rb
Comment thread test/base/date_ordering_test.rb
Comment thread test/base/date_ordering_test.rb
Comment thread test/base/date_ordering_test.rb
@greptile-apps

greptile-apps Bot commented Sep 12, 2026

Copy link
Copy Markdown

Greptile Summary

This PR makes feed date handling consistently select the first valid Time from pubDate, updated, and published.

  • Sorts dated entries newest-first with nanosecond precision and stable tie ordering.
  • Places undated entries after all dated entries, including pre-1970 dates.
  • Preserves merge identity, deduplication, and unidentified-entry placement behavior.
  • Adds documentation and regression coverage for malformed dates, fallbacks, ordering, deduplication, and input immutability.

Confidence Score: 5/5

The PR appears safe to merge, with the changed date-selection and ordering behavior covered by focused regression tests.

No actionable correctness, security, or repository-rule violations remain; the implementation preserves existing identity semantics while preventing malformed date fields from masking valid fallbacks.

Important Files Changed

Filename Overview
lib/simple-rss.rb Centralizes first-valid-date selection and applies stable, precise ordering consistently to latest, filtering, and merge.
test/base/date_ordering_test.rb Adds comprehensive regression coverage for fallback dates, precision, stable ordering, merge deduplication, and unchanged inputs.
test/base/enumerable_test.rb Verifies malformed date values remain accessible while latest ordering succeeds.
test/data/mixed_dates.xml Supplies representative valid, malformed, blank, missing, historical, fallback, and fractional timestamps.
README.md Documents the date precedence, ordering stability, filtering, and merge semantics introduced by the change.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Feed entry] --> B{Valid pubDate?}
  B -- Yes --> E[Use pubDate]
  B -- No --> C{Valid updated?}
  C -- Yes --> F[Use updated]
  C -- No --> D{Valid published?}
  D -- Yes --> G[Use published]
  D -- No --> H[Treat as undated]
  E --> I[Stable newest-first ordering]
  F --> I
  G --> I
  H --> J[Place after dated entries]
Loading

Reviews (1): Last reviewed commit: "fix: handle invalid dates in feed orderi..." | Re-trigger Greptile

@cardmagic
cardmagic merged commit 811f1a2 into master Sep 12, 2026
7 checks passed
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.

Handle invalid dates in feed ordering

2 participants