🐛 Bug Description
When a blog post's frontmatter has an empty tags: field (or tags: null), RelatedPostsFactory fails with runtime errors and prevents the "Related Posts" section from properly calculating recommendations.
There are two failure modes:
- Current post has no tags:
RelatedPostsFactory.getPosts() logs "RelatedPostsFactory: Tags not provided, use setTags()." and returns an empty array [], completely skipping category-based recommendations.
- Candidate post in the pool has no tags:
addTagsPoints() in src/components/Related-Posts/relatedPostsFactory.js:69 invokes .forEach() directly on post.frontmatter.tags with no null check, throwing TypeError: Cannot read properties of null (reading 'forEach').
📍 Location of Bug
- File:
src/components/Related-Posts/relatedPostsFactory.js
- Lines: 34–37 and 65–74
const addTagsPoints = (post, tags) => {
const tagPoint = 1;
const slug = getSlug(post);
// 💥 Crashes when post.frontmatter.tags is null
post.frontmatter.tags.forEach((tag) => {
if (includes(tags, tag)) {
identityMap[slug].points += tagPoint;
}
});
};
🐛 Bug Description
When a blog post's frontmatter has an empty
tags:field (ortags: null),RelatedPostsFactoryfails with runtime errors and prevents the "Related Posts" section from properly calculating recommendations.There are two failure modes:
RelatedPostsFactory.getPosts()logs"RelatedPostsFactory: Tags not provided, use setTags()."and returns an empty array[], completely skipping category-based recommendations.addTagsPoints()insrc/components/Related-Posts/relatedPostsFactory.js:69invokes.forEach()directly onpost.frontmatter.tagswith no null check, throwingTypeError: Cannot read properties of null (reading 'forEach').📍 Location of Bug
src/components/Related-Posts/relatedPostsFactory.js