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

  1. Inspect the allPages array in your gatsby-node to verify every page has a valid `path` string before sitemap generation runs.
  2. Check Gatsby and gatsby-plugin-sitemap versions are compatible (run `npm ls gatsby gatsby-plugin-sitemap`).
  3. Temporarily add logging before the filter to dump page objects that lack a path field to identify the offending source plugin.
  4. 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

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


AI-assisted analysis of gatsbyjs/gatsby@8b06340921 (2026-08-13). Data as JSON: /api/errors/54f79851394b4dd7. Report an issue: GitHub.