{"record":{"id":"54f79851394b4dd7","repo":"gatsbyjs/gatsby","slug":"reporter-prefix-error-in-default-page-filter","errorCode":null,"errorMessage":"${REPORTER_PREFIX} Error in default page filter","messagePattern":"(.+?) Error in default page filter","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/gatsby-plugin-sitemap/src/internals.js","lineNumber":174,"sourceCode":"    typeof filterPages !== `function` ||\n    !Array.isArray(excludes)\n  ) {\n    throw new Error(`Invalid options passed to page Filter function`)\n  }\n\n  // TODO we should optimize these loops\n  const filteredPages = allPages.filter(page => {\n    const defaultFilterMatches = defaultExcludes.some(exclude => {\n      try {\n        const doesMatch = defaultFilterPages(page, exclude, {\n          minimatch,\n          withoutTrailingSlash,\n          resolvePagePath,\n        })\n\n        return doesMatch\n      } catch {\n        throw new Error(`${REPORTER_PREFIX} Error in default page filter`)\n      }\n    })\n\n    if (defaultFilterMatches) {\n      messages.push(\n        `${REPORTER_PREFIX} Default filter excluded page ${resolvePagePath(\n          page\n        )}`\n      )\n    }\n\n    // If page is marked to be excluded via defaults there's no need to check page for custom excludes\n    if (defaultFilterMatches) {\n      return !defaultFilterMatches\n    }\n\n    const customFilterMatches = excludes.some(exclude => {\n      try {","sourceCodeStart":156,"sourceCodeEnd":192,"githubUrl":"https://github.com/gatsbyjs/gatsby/blob/8b06340921ffdf23125a365b9c9923690cb62ce6/packages/gatsby-plugin-sitemap/src/internals.js#L156-L192","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\ncreatePage({ path: '', component: ... })\n// after\ncreatePage({ path: '/valid-path/', component: ... })","handlingStrategy":"validation","validationCode":"// Before calling pageFilter, ensure all pages have valid paths\nconst validPages = allPages.filter(page => typeof page?.path === 'string' && page.path.length > 0)\nif (validPages.length !== allPages.length) {\n  console.warn(`${allPages.length - validPages.length} pages have invalid paths`)\n}\npageFilter({ allPages: validPages, filterPages, excludes })","typeGuard":"const hasValidPath = (page: unknown): page is { path: string } =>\n  typeof page === 'object' && page !== null && typeof (page as any).path === 'string' && (page as any).path.length > 0","tryCatchPattern":null,"preventionTips":["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."],"tags":["gatsby","sitemap","filtering","page-nodes"],"backgroundTag":null,"analyzedSha":"8b06340921ffdf23125a365b9c9923690cb62ce6","analyzedAt":"2026-08-13T02:36:21.405Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}