Validate your RSS feed

Published on

Today a dear user made me aware that my RSS feed broke. There was a XML Parsing Error for

ASAP after work I checked the validity through and in fact there were some issues with it.

Apparently a mismatched tag </link> was causing the parser to go berserk.

After understanding the issue, I simplified the (which generates the rss.xml through devblog) and used as an example.

Stripped away all the tags I didn’t need, and this is the resulting version of

<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
  <title>Christian Fei's Blog</title>
  <description>A blog about my programming adventures in Elixir, Node.js and JavaScript</description>
  {%-  for post in -%}
    <title><![CDATA[{{ }}]]></title>
    <link><![CDATA[{{ post.url | withDomain }}]]></link>
    <guid><![CDATA[{{ post.url | withDomain }}]]></guid>
    <description><![CDATA[{{ post.text }}]]></description>
  {%-  endfor -%}

This file is processed with devblog and loops through the collections of posts, creating a list of <item> elements that represent the RSS feed.

The reverse nunjucks filter is needed because files are listed in alphabetical order, which means I would have the oldest post first otherwise.

Validating the RSS feed in the CI

I wanted to add this build step in the Continuous Integration I have set up with a GitHub Actions workflow.

If the validation of the RSS feed fails, the CI should not deploy a new version of the blog to

Looking on NPM I found this little gem (pun intended) called feed-validator.

Which I use in my GitHub Actions workflow’s main.yml in the following way:

      - name: build
        run: |
          npm run build
          npm run compress
      - name: start server
        run: |
           npm start &
      - name: rss validation
        run: |
          npx feed-validator
      - name: uat
        uses: cypress-io/github-action@v1
      - name: deploy
          AWS_ACCESS_KEY_ID: $
        run: |
          npm run deploy-with-assets

You could also run it via file with the [-c FILE_PATH] option.

This small module calls the validation endpoint on for me. In other words, this could be done with a cURL call, but that’s for another time.

Here the code that does the API call to

Here’s the full rss.xml feed, if you’re into that.

PS: did you remember that RSS was initially called RDF Site Summary, and then Really Simple Syndication or Rich Site Summary? ~ Wikipedia

Here, have a slice of pizza 🍕