Skip to content

fix(workers): honor RSS/Atom entry date as bookmark created date - #2943

Open
TowyTowy wants to merge 1 commit into
karakeep-app:mainfrom
TowyTowy:fix/rss-feed-published-date
Open

fix(workers): honor RSS/Atom entry date as bookmark created date#2943
TowyTowy wants to merge 1 commit into
karakeep-app:mainfrom
TowyTowy:fix/rss-feed-published-date

Conversation

@TowyTowy

Copy link
Copy Markdown

Description

RSS/Atom feed entries carry a publication date (<pubDate> for RSS, <updated>/<published> for Atom), which rss-parser normalizes into isoDate. The feed worker ignored it and always created bookmarks with the fetch-time default, so entries imported from a feed were dated when the feed was polled instead of when they were published (e.g. a Reddit saved-posts feed shows "today" for every item).

This makes RSS ingestion consistent with file imports, which already honor their source date via sourceAddedAt -> createdAt in the import worker.

Changes:

  • feedParser: parse the entry's published date (isoDate, falling back to raw pubDate) into a publishedAt: Date | undefined.
  • feedWorker: pass it as createdAt when creating the bookmark; when the feed omits a date we send undefined and the server default is used.

Scope: this fixes the date half of the issue. The author part is a separate, crawler-side concern (link author is populated by the crawl and createBookmark has no author field for links), so it's intentionally left out of this PR.

Fixes #2334

How Has This Been Tested?

  • Added feedParser unit tests (vitest): RSS <pubDate>, Atom <updated> (Reddit-style), and the no-date fallback (publishedAt undefined). Fail before the fix, pass after.
  • pnpm --filter @karakeep/workers typecheck, oxfmt --check, oxlint all clean.

Checklist:

  • I have carefully read CONTRIBUTING.md
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation if applicable
  • I have no unrelated changes in the PR.
  • I have confirmed that any new dependencies are strictly necessary. (none added)
  • I have written tests for new code (if applicable)

Please describe to which degree, if any, an LLM was used in creating this pull request.

This PR was written with substantial help from an AI coding assistant (Anthropic Claude), which located the bug, wrote the code and tests, and ran the checks. All changes were reviewed by me before submission, and I take responsibility for them.

Feed entries carry a publication date (RSS `<pubDate>`, Atom
`<updated>`/`<published>`), which rss-parser normalizes into `isoDate`.
The feed worker ignored it and always created bookmarks with the
fetch-time default, so imported entries were dated when the feed was
polled rather than when they were published.

Extract the entry's published date in the feed parser and pass it as
`createdAt` when creating the bookmark, falling back to the server
default when the feed omits a date. This mirrors how file imports
already honor their source date (`sourceAddedAt`).

Fixes karakeep-app#2334

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@greptile-apps

greptile-apps Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR makes feed imports preserve entry publication dates. The main changes are:

  • Parse RSS and Atom item dates into publishedAt.
  • Pass publishedAt as createdAt when creating feed bookmarks.
  • Add parser tests for RSS dates, Atom dates, and missing dates.

Confidence Score: 5/5

This looks safe to merge after a small date-fallback cleanup.

  • Bookmark creation already accepts optional created dates.
  • Missing feed dates still fall back to the server default.
  • One parser edge case can lose a usable raw date when the normalized date is present but invalid.

apps/workers/workers/utils/feedParser.ts

Important Files Changed

Filename Overview
apps/workers/workers/feedWorker.ts The feed worker now forwards each parsed item date as the bookmark creation date.
apps/workers/workers/utils/feedParser.ts The parser now extracts isoDate or pubDate into publishedAt, with a small fallback edge case for invalid normalized dates.
apps/workers/workers/utils/feedParser.test.ts Parser tests now cover RSS pubDate, Atom dates, and missing-date behavior.
Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 1
apps/workers/workers/utils/feedParser.ts:43
**Invalid Normalized Date Blocks Fallback**

When `rss-parser` provides an `isoDate` string that is present but not parseable, this chooses it before checking `pubDate`. A feed item with a usable raw `pubDate` can then get `publishedAt` set to `undefined`, so the worker stores the bookmark with the fetch-time default instead of the entry date.

```suggestion
    publishedAt: parseFeedDate(item.isoDate) ?? parseFeedDate(item.pubDate),
```

Reviews (1): Last reviewed commit: "fix(workers): honor RSS/Atom entry date ..." | Re-trigger Greptile

.transform((item) => ({
...item,
guid: item.guid ?? item.id ?? item.link,
publishedAt: parseFeedDate(item.isoDate ?? item.pubDate),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Invalid Normalized Date Blocks Fallback

When rss-parser provides an isoDate string that is present but not parseable, this chooses it before checking pubDate. A feed item with a usable raw pubDate can then get publishedAt set to undefined, so the worker stores the bookmark with the fetch-time default instead of the entry date.

Suggested change
publishedAt: parseFeedDate(item.isoDate ?? item.pubDate),
publishedAt: parseFeedDate(item.isoDate) ?? parseFeedDate(item.pubDate),
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/workers/workers/utils/feedParser.ts
Line: 43

Comment:
**Invalid Normalized Date Blocks Fallback**

When `rss-parser` provides an `isoDate` string that is present but not parseable, this chooses it before checking `pubDate`. A feed item with a usable raw `pubDate` can then get `publishedAt` set to `undefined`, so the worker stores the bookmark with the fetch-time default instead of the entry date.

```suggestion
    publishedAt: parseFeedDate(item.isoDate) ?? parseFeedDate(item.pubDate),
```

How can I resolve this? If you propose a fix, please make it concise.

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.

(Reddit) RSS feed not respecting provided metadata (date/author)

1 participant