Cannot read properties of undefined (reading 'filter')
Operating system
macOS Sonoma 14.4.1
Eleventy
3.0.0-alpha.13
Describe the bug
When trying to build a project which works fine in Eleventy 2.0.1, using Eleventy 3.0.0-alpha.13, the build fails with the following error:
[11ty] Cannot read properties of undefined (reading 'filter') (via TypeError)
[11ty]
[11ty] Original error stack trace: TypeError: Cannot read properties of undefined (reading 'filter')
[11ty] at TemplateData.getIncludedTagNames (file://node_modules/@11ty/eleventy/src/Data/TemplateData.js:703:22)
[11ty] at file://node_modules/@11ty/eleventy/src/TemplateCollection.js:64:33
[11ty] at Array.filter (<anonymous>)
[11ty] at TemplateCollection.getFilteredByTag (file://node_modules/@11ty/eleventy/src/TemplateCollection.js:63:30)
[11ty] at TemplateMap.getTaggedCollection (file://node_modules/@11ty/eleventy/src/TemplateMap.js:613:29)
[11ty] at TemplateMap.setCollectionByTagName (file://node_modules/@11ty/eleventy/src/TemplateMap.js:379:41)
[11ty] at TemplateMap.initDependencyMap (file://node_modules/@11ty/eleventy/src/TemplateMap.js:401:16)
[11ty] at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
[11ty] at async TemplateMap.cache (file://node_modules/@11ty/eleventy/src/TemplateMap.js:444:3)
[11ty] at async TemplateWriter._createTemplateMap (file://node_modules/@11ty/eleventy/src/TemplateWriter.js:319:3)
As there's no pointer to a particular project template or file, it's hard to work out what content is causing this to happen, or how to create a minimal reproduction. The DEBUG mode doesn't appear to output anything that jumps out at me, but happy to provide additional details.
The error seems to relate to the tags data not being an array, as expected by the TemplateData.getIncludedTagNames
method. The site content does often define tags
as a single string (instead of an array), in templates of both Liquid and Markdown, as well as via data files. This has previously been abstracted away by Eleventy 2.x.
Reproduction steps
- Unknown aspect of content, potentially related to
tags
being defined as a string and not an array - Upgrade project to Eleventy 3
- Build
Expected behavior
The project should build without errors, without having to change all previous content.
Reproduction URL
No response
Screenshots
No response