gatsbyjs/gatsby · error · Error
${REPORTER_PREFIX} Error in default page filter
Error message
${REPORTER_PREFIX} Error in default page filter What it means
Thrown by gatsby-plugin-sitemap's page filtering logic when the internal default page filter function throws an exception while testing a page against a default exclude pattern. The catch block wraps any underlying error from defaultFilterPages, minimatch, or path resolution utilities into this generic message, discarding the original error's details.
Source
Thrown at packages/gatsby-plugin-sitemap/src/internals.js:174
typeof filterPages !== `function` ||
!Array.isArray(excludes)
) {
throw new Error(`Invalid options passed to page Filter function`)
}
// TODO we should optimize these loops
const filteredPages = allPages.filter(page => {
const defaultFilterMatches = defaultExcludes.some(exclude => {
try {
const doesMatch = defaultFilterPages(page, exclude, {
minimatch,
withoutTrailingSlash,
resolvePagePath,
})
return doesMatch
} catch {
throw new Error(`${REPORTER_PREFIX} Error in default page filter`)
}
})
if (defaultFilterMatches) {
messages.push(
`${REPORTER_PREFIX} Default filter excluded page ${resolvePagePath(
page
)}`
)
}
// If page is marked to be excluded via defaults there's no need to check page for custom excludes
if (defaultFilterMatches) {
return !defaultFilterMatches
}
const customFilterMatches = excludes.some(exclude => {
try {View on GitHub (pinned to 8b06340921)
Solutions
- Inspect the allPages array in your gatsby-node to verify every page has a valid `path` string before sitemap generation runs.
- Check Gatsby and gatsby-plugin-sitemap versions are compatible (run `npm ls gatsby gatsby-plugin-sitemap`).
- Temporarily add logging before the filter to dump page objects that lack a path field to identify the offending source plugin.
- If using a custom createPage call, ensure each page is created with a non-empty string path.
Example fix
// before
createPage({ path: '', component: ... })
// after
createPage({ path: '/valid-path/', component: ... }) Defensive patterns
Strategy: validation
Validate before calling
// Before calling pageFilter, ensure all pages have valid paths
const validPages = allPages.filter(page => typeof page?.path === 'string' && page.path.length > 0)
if (validPages.length !== allPages.length) {
console.warn(`${allPages.length - validPages.length} pages have invalid paths`)
}
pageFilter({ allPages: validPages, filterPages, excludes }) Type guard
const hasValidPath = (page: unknown): page is { path: string } =>
typeof page === 'object' && page !== null && typeof (page as any).path === 'string' && (page as any).path.length > 0 Prevention
- Validate page objects from source plugins have a non-empty string path field before sitemap generation.
- Run integration tests that assert every page created via createPage has a valid path.
- Log page shapes during development to catch malformed nodes early.
When it happens
Trigger: The defaultExcludes.some() loop calls defaultFilterPages() for every page; if the page object lacks expected properties (e.g., path is undefined), or if withoutTrailingSlash/resolvePagePath receive malformed input, the inner call throws and is caught by the bare `catch {}` which rethrows this generic message.
Common situations: Pages created by other plugins that have a non-standard shape (missing or null path field), corrupted page nodes from a source plugin, or a Gatsby version mismatch where the page object schema changed.
Related errors
- ${REPORTER_PREFIX} Error in custom page filter. If you've cu
- Invalid plugin options for "gatsby-plugin-sitemap":
- 'babel-plugin-styled-components' is not installed which is n
- Couldn't check available APIs. Make sure you are on gatsby v
- Couldn't check available APIs. Make sure you are on gatsby v
AI-assisted analysis of gatsbyjs/gatsby@8b06340921 (2026-08-13).
Data as JSON: /api/errors/54f79851394b4dd7.
Report an issue: GitHub.