{"record":{"id":"00b5752530e79b12","repo":"gatsbyjs/gatsby","slug":"an-error-occurred-building-the-slug-parts-this-is","errorCode":null,"errorMessage":"An error occurred building the slug parts. This is likely a bug within Gatsby and not your code. Please report it to us if you run into this.","messagePattern":"An error occurred building the slug parts\\. This is likely a bug within Gatsby and not your code\\. Please report it to us if you run into this\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/gatsby-plugin-page-creator/src/path-utils.ts","lineNumber":42,"sourceCode":"}\n\n// Remove trailing slash\nexport function stripTrailingSlash(str: string): string {\n  return str.endsWith(`/`) ? str.slice(0, -1) : str\n}\n\nconst curlyBracesContentsRegex = /\\{.*?\\}/g\n\n// This extracts all information in an absolute path to an array of each collection part\n// /foo/{Model.bar}/{Model.baz} => ['Model.bar', 'Model.baz']\nexport function extractAllCollectionSegments(\n  absolutePath: string\n): Array<string> {\n  const slugParts = absolutePath.match(curlyBracesContentsRegex)\n\n  // This shouldn't happen - but TS requires us to validate\n  if (!slugParts) {\n    throw new Error(\n      `An error occurred building the slug parts. This is likely a bug within Gatsby and not your code. Please report it to us if you run into this.`\n    )\n  }\n\n  return slugParts\n}\n\nconst extractFieldWithoutUnionRegex = /\\(.*\\)__/g\n\n/**\n * Given a filePath part that is a collection marker it do this transformation:\n * @param {string} filePart - The individual part of the URL\n * @returns {Array<string>} - Returns an array of extracted fields (with converted \"Unions\")\n * @example\n * {Model.bar} => bar\n * {Model.field__bar} => field__bar\n * {Model.field__(Union)__bar} => field__bar\n */","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/gatsbyjs/gatsby/blob/8b06340921ffdf23125a365b9c9923690cb62ce6/packages/gatsby-plugin-page-creator/src/path-utils.ts#L24-L60","documentation":"path-utils.ts extractAllCollectionSegments runs the regex /\\{.*?\\}/g on an absolute path to pull out every {Model.field} token. The match returns null when there are no curly-brace segments at all. Because this function is only called on paths already classified as collection paths, a null result signals an internal inconsistency the user cannot cause through normal config - hence the message asks the user to report it as a Gatsby bug.","triggerScenarios":"Internal: the page-creator's classification step decided a path is a collection path (e.g. it contained a brace at one stage) but by the time extractAllCollectionSegments runs the braces are gone - typically through path normalization, symlinks, or a transform that stripped characters. Effectively unreachable through normal user input.","commonSituations":"Rare. Has appeared after upgrades that changed path handling, with unusual filesystems (Windows UNC paths), or when a custom onCreateNode mutates the absolute path. If a user sees it, it is almost always a Gatsby regression worth reporting with a reproduction.","solutions":["Update to the latest patch of gatsby and gatsby-plugin-page-creator; this path is internal and bugs are fixed upstream.","Remove or simplify any custom code that rewrites node/file paths in onCreateNode or onCreatePage.","If reproducible, file a Gatsby issue with the exact file path, OS, and package versions.","As a workaround, rename the file so it does not use a collection segment, or move it out of src/pages and create the page manually via createPage."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"function safeExtractSegments(absolutePath) {\n  const m = absolutePath.match(/\\{.*?\\}/g);\n  if (!m) return []; // graceful: treat as non-collection instead of throwing\n  return m;\n}","typeGuard":"function hasCollectionSegment(absolutePath) {\n  return /\\{.*?\\}/.test(absolutePath);\n}","tryCatchPattern":"try {\n  const segments = extractAllCollectionSegments(absolutePath);\n} catch (e) {\n  // This path is documented as an internal Gatsby bug; fall back to treating\n  // the path as a normal (non-collection) page and report upstream.\n  reporter.warn(`Skipping collection extraction for ${absolutePath}: ${e.message}`);\n}","preventionTips":["Treat this error as a bug report trigger; capture the exact path and Gatsby version.","Avoid custom node-path rewrites that could strip braces before page creation.","Pin gatsby-plugin-page-creator to a known-good version if it appears after an upgrade."],"tags":["gatsby-plugin-page-creator","internal","bug","collection-path"],"backgroundTag":null,"analyzedSha":"8b06340921ffdf23125a365b9c9923690cb62ce6","analyzedAt":"2026-08-13T02:36:21.405Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}