gatsbyjs/gatsby · error

11334

11334

Error message

${pluginName} must set the slice id when creating a slice.\n\nThe slice object passed to createSlice:\n${sliceObject}

What it means

Thrown by the createSlice action when payload.id is falsy. Slices (Gatsby v5, behind GATSBY_SLICES) require an id; omitting it panics with code 11334, including the offending slice object and the plugin name. Note: the inner message string reuses 'page path' wording even though this is the slice-id check (a copy-paste artifact in the source).

Source

Thrown at packages/gatsby/src/redux/actions/restricted.ts:473

   *     id: `navigation-bar`,
   *     component: path.resolve(`./src/components/navigation-bar.js`),
   *   })
   * }
   */
  createSlice: (
    payload: ICreateSliceInput,
    plugin: IGatsbyPlugin,
    traceId?: string
  ): ICreateSliceAction => {
    if (_CFLAGS_.GATSBY_MAJOR === `5` && process.env.GATSBY_SLICES) {
      let name = `The plugin "${plugin.name}"`
      if (plugin.name === `default-site-plugin`) {
        name = `Your site's "gatsby-node.js"`
      }

      if (!payload.id) {
        const message = `${name} must set the page path when creating a slice`
        report.panic({
          id: `11334`,
          context: {
            pluginName: name,
            sliceObject: payload,
            message,
          },
        })
      }

      const { slices } = store.getState()

      const { error, panicOnBuild } = validateComponent({
        input: payload,
        pluginName: name,
        errorIdMap: {
          noPath: `11333`,
          notAbsolute: `11335`,
          doesNotExist: `11336`,

View on GitHub (pinned to 8b06340921)

Solutions

  1. Pass a stable, unique non-empty `id` string in every createSlice call.
  2. Derive id from your data (e.g. slice.id = `header` or `${template}-${locale}`) and ensure it is never null.
  3. Enable Slices explicitly via GATSBY_SLICES=true on Gatsby v5+.

Example fix

// before
actions.createSlice({ component, context })
// after
actions.createSlice({ id: `site-header`, component, context })
Defensive patterns

Strategy: validation

Validate before calling

if (!payload.id || typeof payload.id !== 'string') {
  throw new Error('createSlice requires a non-empty id string')
}
actions.createSlice(payload)

Type guard

function hasSliceId(p): p is { id: string } {
  return typeof p?.id === 'string' && p.id.length > 0
}

Prevention

When it happens

Trigger: A call to actions.createSlice where payload.id is undefined/null/empty; the !payload.id branch fires inside the GATSBY_MAJOR===5 && GATSBY_SLICES guard.

Common situations: Adopting Slices and forgetting to set id; using a data field for id that is null for some records; misreading the API and passing `name` instead of `id`.

Related errors


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