{"record":{"id":"34948fb4ca9f6048","repo":"gatsbyjs/gatsby","slug":"you-ve-passed-something-other-than-string-to-the-e","errorCode":null,"errorMessage":"You've passed something other than string to the exclude array. This is supported, but you'll have to write a custom filter function.\nIgnoring the input for now: ${JSON.stringify(excludedRoute, null, 2)}\nhttps://www.gatsbyjs.com/plugins/gatsby-plugin-sitemap/#api-reference\n      ","messagePattern":"You've passed something other than string to the exclude array\\. This is supported, but you'll have to write a custom filter function\\.\nIgnoring the input for now: (.+?)\nhttps://www\\.gatsbyjs\\.com/plugins/gatsby-plugin-sitemap/#api-reference\n      ","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/gatsby-plugin-sitemap/src/internals.js","lineNumber":110,"sourceCode":" *\n * This allows filtering any data in any way.\n *\n * This Function is executed via allPages.filter((page) => !excludes.some((excludedRoute) => thisFunc(page, ecludedRoute, tools)))\n * allPages is the results of the resolvePages\n *\n * @param {object} page\n * @param {string} excludedRoute - Array from plugin config `options.exclude`\n * @param {object} tools - contains required tools for filtering\n *\n * @returns {boolean}\n */\nexport function defaultFilterPages(\n  page,\n  excludedRoute,\n  { minimatch, withoutTrailingSlash, resolvePagePath }\n) {\n  if (typeof excludedRoute !== `string`) {\n    throw new Error(\n      `You've passed something other than string to the exclude array. This is supported, but you'll have to write a custom filter function.\nIgnoring the input for now: ${JSON.stringify(excludedRoute, null, 2)}\nhttps://www.gatsbyjs.com/plugins/gatsby-plugin-sitemap/#api-reference\n      `\n    )\n  }\n\n  // Minimatch is always scary without an example\n  // TODO add example\n  return minimatch(\n    withoutTrailingSlash(resolvePagePath(page)),\n    withoutTrailingSlash(excludedRoute)\n  )\n}\n\n/**\n * @name serialize\n *","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/gatsbyjs/gatsby/blob/8b06340921ffdf23125a365b9c9923690cb62ce6/packages/gatsby-plugin-sitemap/src/internals.js#L92-L128","documentation":"gatsby-plugin-sitemap's defaultFilterPages applies each entry of the `exclude` option against page URLs via minimatch. The default implementation only handles string entries (glob patterns). If an entry is not a string (a RegExp, function, object, or number), it throws and points the user to the API reference to supply a custom `filterPages` function instead. The message says non-string entries are 'supported' only via a custom filter, not via the default.","triggerScenarios":"Configuring the plugin with options.exclude containing a RegExp (e.g. /\\/draft\\//), a function, an object, or any non-string, e.g. { resolve: 'gatsby-plugin-sitemap', options: { exclude: ['/secret', /\\?lang=/] } }.","commonSituations":"Wanting regex exclusion (common need) and assuming the default filter accepts RegExp; migrating from another sitemap plugin that allowed functions; passing an object like { path: '/x' } by mistake.","solutions":["Convert RegExp excludes to minimatch glob strings, e.g. use '/draft/**' instead of /\\/draft\\//.","If you need RegExp/function logic, provide a custom options.filterPages function and do the matching yourself.","Ensure every element of the exclude array is a string when using the default filter."],"exampleFix":"// before\n{\n  resolve: `gatsby-plugin-sitemap`,\n  options: { exclude: [`/secret`, /\\?lang=/] }\n}\n\n// after (glob string)\n{\n  resolve: `gatsby-plugin-sitemap`,\n  options: { exclude: [`/secret`, `/*?lang=*`] }\n}\n// or custom filter for regex logic\noptions: { filterPages: (page, excludedRoutes) => excludedRoutes.every(...) }","handlingStrategy":"type-guard","validationCode":"function normalizeExcludes(exclude) {\n  const arr = Array.isArray(exclude) ? exclude : [];\n  const bad = arr.filter(e => typeof e !== 'string');\n  if (bad.length) {\n    throw new Error('gatsby-plugin-sitemap exclude entries must be strings; ' +\n      'use a custom filterPages for RegExp/function logic.');\n  }\n  return arr;\n}","typeGuard":"function isStringArray(arr) {\n  return Array.isArray(arr) && arr.every(e => typeof e === 'string');\n}","tryCatchPattern":null,"preventionTips":["Express excludes as minimatch globs, not RegExp.","Provide a custom filterPages function when you need regex/function matching.","Lint gatsby-config.js to assert exclude is a string[]."],"tags":["gatsby-plugin-sitemap","config","validation","exclude"],"backgroundTag":null,"analyzedSha":"8b06340921ffdf23125a365b9c9923690cb62ce6","analyzedAt":"2026-08-13T02:36:21.405Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}