{"record":{"id":"d1b4a7054051f2b8","repo":"gatsbyjs/gatsby","slug":"slice-name-slicename-not-found-when-rendering","errorCode":null,"errorMessage":"Slice name \"${sliceName}\" not found when rendering slices","messagePattern":"Slice name \"(.+?)\" not found when rendering slices","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/gatsby/src/utils/worker/child/render-html.ts","lineNumber":702,"sourceCode":"export async function renderSlices({\n  slices,\n  htmlComponentRendererPath,\n  publicDir,\n  slicesProps,\n  staticQueriesBySliceTemplate,\n}: {\n  publicDir: string\n  slices: Array<[string, IGatsbySlice]>\n  slicesProps: Array<ISlicePropsEntry>\n  htmlComponentRendererPath: string\n  staticQueriesBySliceTemplate: Record<string, Array<string>>\n}): Promise<void> {\n  const htmlComponentRenderer = require(htmlComponentRendererPath)\n\n  for (const { sliceId, props, sliceName, hasChildren } of slicesProps) {\n    const sliceEntry = slices.find(f => f[0] === sliceName)\n    if (!sliceEntry) {\n      throw new Error(\n        `Slice name \"${sliceName}\" not found when rendering slices`\n      )\n    }\n    const slice = sliceEntry[1]\n    const staticQueryHashes =\n      staticQueriesBySliceTemplate[slice.componentPath] || []\n\n    const { staticQueryContext } = await getStaticQueryContext(\n      staticQueryHashes\n    )\n\n    const MAGIC_CHILDREN_STRING = `__DO_NOT_USE_OR_ELSE__`\n    const sliceData = await readSliceData(publicDir, slice.name)\n\n    try {\n      const html = await htmlComponentRenderer.renderSlice({\n        slice,\n        staticQueryContext,","sourceCodeStart":684,"sourceCodeEnd":720,"githubUrl":"https://github.com/gatsbyjs/gatsby/blob/8b06340921ffdf23125a365b9c9923690cb62ce6/packages/gatsby/src/utils/worker/child/render-html.ts#L684-L720","documentation":"Thrown in `renderSlices` while iterating `slicesProps`. For each entry it looks up the slice by name in the `slices` array via `slices.find(f => f[0] === sliceName)`; if no slice is registered under that name, rendering cannot proceed. It signals a divergence between the set of slices registered for the build and the slice props/ids queued for HTML rendering.","triggerScenarios":"A `slicesProps` entry references a `sliceName` that was not included in the `slices` array passed to `renderSlices`. This arises when a slice is referenced by a page but its registration (via `createSlice` / the slice API) was skipped, or when the slice name was renamed between when props were computed and when the render worker received the slice list.","commonSituations":"Renaming a Slice without updating all `Slice` component usages; deleting a Slice definition but leaving references in templates; partial cache where slice registration metadata is stale relative to the page data referencing it.","solutions":["Confirm every `sliceName` in `slicesProps` corresponds to a Slice registered via `createSlice` in `gatsby-node`.","Clear `.cache` and rebuild: `rm -rf .cache public && gatsby build`.","Grep templates for `<Slice alias=\"...\">` usages and ensure each alias matches a registered slice name.","If a Slice was renamed, update all references consistently and re-run the build."],"exampleFix":"// before: alias does not match a registered slice\n<Slice alias=\"header-bar\" />\n\n// gatsby-node.js registers it as\ncreateSlice({ id: 'header', component: require.resolve('./src/slices/header.tsx') })\n\n// after: make alias match the registered id\n<Slice alias=\"header\" />","handlingStrategy":"validation","validationCode":"// Before render, assert every referenced slice is registered\nconst registered = new Set(slices.map(s => s[0]))\nconst missing = slicesProps.filter(p => !registered.has(p.sliceName))\nif (missing.length) throw new Error(`Missing slices: ${missing.map(m => m.sliceName).join(', ')}`)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Register every Slice via `createSlice` before referencing it.","Keep `<Slice alias>` usages in sync with registered slice ids.","Clear `.cache` after renaming or removing slices."],"tags":["slices","render-html","ssg","slice-registration","build"],"backgroundTag":null,"analyzedSha":"8b06340921ffdf23125a365b9c9923690cb62ce6","analyzedAt":"2026-08-13T02:36:21.405Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}