MagicMirrorOrg / MagicMirrorOrg/MagicMirror

[Bug] Newsfeed crashes when an Atom summary is parsed as an object

Open Beginner friendly
#4,212 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug ready (coming with next release)
Dominant language
JavaScript
Stars
23.9k
Forks
4.6k
Avg merge
17h 31m
Merged PRs (30d)
25

Description

Environment

MagicMirror version: 2.37.0
Node.js version: 24.11.0
npm version: 11.11.0
Platform: Raspberry Pi 5
Operating system: Raspberry Pi OS Bookworm
Process manager: PM2

Which start option are you using?

node --run start:x11

Are you using PM2?

Yes

Module

newsfeed

Have you tried disabling other modules?
  • Yes
  • No
Have you searched if someone else has already reported the issue on the forum or in the issues?
  • Yes
What did you do?

Newsfeed crashes when an Atom summary is parsed as an object

Description

The default newsfeed module fails to process the VRT NWS Atom feed:

https://www.vrt.be/vrtnieuws/nl.rss.articles.xml

MagicMirror logs the following error:

[ERROR] [newsfeed] https://www.vrt.be/vrtnieuws/nl.rss.articles.xml - Stream processing failed: this.buffers[0].slice is not a function
[ERROR] [newsfeed] Error: Could not fetch newsfeed: https://www.vrt.be/vrtnieuws/nl.rss.articles.xml Stream processing failed: this.buffers[0].slice is not a function

Environment

  • MagicMirror version: 2.37.0
  • Node.js version: 24.11.0
  • npm version: 11.11.0
  • Platform: Raspberry Pi 5
  • Operating system: Raspberry Pi OS Bookworm
  • Process manager: PM2

Reproduction

Configure the default newsfeed module with:

{
    title: "VRT NWS",
    url: "https://www.vrt.be/vrtnieuws/nl.rss.articles.xml"
}

Restart MagicMirror.

The feed is downloaded successfully, but processing fails with:

this.buffers[0].slice is not a function

The URL responds successfully after its redirect:

HTTP/2 301
HTTP/2 200
content-type: application/atom+xml;charset=utf-8

Investigation

Parsing all 50 feed entries with feedme showed that five entries return summary as an object rather than a string:

ITEM 2 FIELD summary TYPE object VALUE { type: 'text' }
ITEM 4 FIELD summary TYPE object VALUE { type: 'text' }
ITEM 6 FIELD summary TYPE object VALUE { type: 'text' }
ITEM 45 FIELD summary TYPE object VALUE { type: 'text' }
ITEM 47 FIELD summary TYPE object VALUE { type: 'text' }
Finished: 50 items, 5 non-string fields

The relevant code in defaultmodules/newsfeed/newsfeedfetcher.js selects the first available description field:

let description = item.description || item.summary || item.content || "";

It later passes description to htmlToText() without checking whether it is a string.

When description is { type: "text" }, html-to-text/htmlparser2 ultimately throws:

this.buffers[0].slice is not a function

Workaround

Adding a type guard before calling htmlToText() prevents the whole feed from failing:

let description = item.description || item.summary || item.content || "";

if (typeof description !== "string") {
    Log.warn(`Unexpected non-string description for ${this.url}:`, description);
    description = "";
}

After this change, the VRT newsfeed loads normally. Entries with object-valued summaries are retained with an empty description instead of crashing the complete feed.

Expected behavior

A malformed or unusually parsed description or summary in one feed item should not prevent the entire feed from loading.

The newsfeed module should either:

  1. normalize supported object structures into text;
  2. discard only the invalid description field; or
  3. skip only the affected item while continuing to process the remaining entries.
What did you expect to happen?

A malformed or unusually parsed description or summary in one feed item should not prevent the entire feed from loading.

The newsfeed module should either:

  1. normalize supported object structures into text;
  2. discard only the invalid description field; or
  3. skip only the affected item while continuing to process the remaining entries.
What actually happened?

The default newsfeed module fails to process the VRT NWS Atom feed:

https://www.vrt.be/vrtnieuws/nl.rss.articles.xml

MagicMirror logs the following error:

[ERROR] [newsfeed] https://www.vrt.be/vrtnieuws/nl.rss.articles.xml - Stream processing failed: this.buffers[0].slice is not a function
[ERROR] [newsfeed] Error: Could not fetch newsfeed: https://www.vrt.be/vrtnieuws/nl.rss.articles.xml Stream processing failed: this.buffers[0].slice is not a function

Additional comments

diff --git a/defaultmodules/newsfeed/newsfeedfetcher.js b/defaultmodules/newsfeed/newsfeedfetcher.js
index b6b86fe5..5e2ae3a7 100644
--- a/defaultmodules/newsfeed/newsfeedfetcher.js
+++ b/defaultmodules/newsfeed/newsfeedfetcher.js
@@ -152,6 +152,10 @@ class NewsfeedFetcher {
parser.on("item", (item) => {
const title = item.title;
let description = item.description || item.summary || item.content || "";

  •                   if (typeof description !== "string") {
    
  •                           Log.warn(`Unexpected non-string description for ${this.url}:`, description);
    
  •                           description = "";
    
  •                   }
                      const pubdate = item.pubdate || item.published || item.updated || item["dc:date"] || item["a10:updated"];
                      const url = item.url || item.link || "";
    
Participation
  • I am willing to submit a pull request for this change.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in defaultmodules/newsfeed/newsfeedfetcher.js around the item handler and the description selection shown in the issue. Reproduce with the VRT NWS Atom feed, then verify that an object-valued summary no longer crashes processing and that the remaining feed entries still load. No specific test file is named in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
78/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.