Skip to content

Unexpected behaviour in RSS/Atom feeds if a document has an empty "updated" date #280

@jermdavis

Description

@jermdavis

I've come across a behaviour that confused me with how document dates are handled with feed generation. Not sure if this is a bug, or my lack of understanding of the "right way of doing stuff" but figured I should raise it in case...

(I've reproduced it with a single post and a single feeds.yml file and no other files in a fresh beta 60 project, so am fairly sure this isn't something caused by customisations in my website's source)

If I have a "blog post" document whose front matter includes:

Published: 2025-February-06
Updated:

Then when this item appears in a feed, the published date will be rendered as DateTime.MinValue, despite a valid published date value being in the front matter:

<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" version="2.0">
	<channel>
		<pubDate>Tue, 20 May 2025 10:12:30 GMT</pubDate>
		<lastBuildDate>Tue, 20 May 2025 10:12:30 GMT</lastBuildDate>
		<item>
			....
			<pubDate>Mon, 01 Jan 0001 00:00:00 GMT</pubDate>
			...
		</item>
	</channel>
</rss>

If the empty Updated: field is removed from the front matter or its value is set to a valid date, this goes back to generating the correct data in the feed.

It looks like this happens because when the front matter data is parsed to create the generic feed item, data is stored as a DateTime? in FeedItem but the parsed value appears to be DateTime.MinValue not null for the empty Updated field. And when this is then converted into an RssItem it checks if the updated property is null or not - so overwrites the published date with the MinValue in Updated rather than skipping over a null value. And that gives the wrong date in the feed.

So I can see that removing the empty Updated: property from my post would fix this in my case. But the framework's code made me wonder if this was incorrect behaviour?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions