{"record":{"id":"a1d8e6e3791eae35","repo":"gatsbyjs/gatsby","slug":"the-id-parameter-passed-to-createnodeid-must-be","errorCode":null,"errorMessage":"The `id` parameter passed to createNodeId must be a String or Number (got ${typeof id})","messagePattern":"The `id` parameter passed to createNodeId must be a String or Number \\(got (.+?)\\)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"packages/gatsby/src/utils/create-node-id.ts","lineNumber":40,"sourceCode":" * - The conversion needs to be fast\n * - The result should be predictably short as it may be used in urls\n *\n * High level this step is meant to prevent people from using our `id` to have meaning in their site and it's meant\n * to make sure the id ends up being short, whatever the input size was.\n *\n * Note: UUID is relatively slow because it calls into the native crypto library to generate SHA-1 hashes.\n *       We do need the low collision rate of SHA-1 so we use a local (global) cache to speed up repetitive calls\n *\n * @param {String | Number} id - A string of arbitrary length\n * @param {String} namespace - Namespace to use for UUID\n *\n * @return {String} - UUID\n */\nexport function createNodeId(id: string | number, namespace: string): string {\n  if (typeof id === `number`) {\n    id = id.toString()\n  } else if (typeof id !== `string`) {\n    report.panic(\n      `The \\`id\\` parameter passed to createNodeId must be a String or Number (got ${typeof id})`\n    )\n  } else if (typeof namespace !== `string`) {\n    report.panic(\n      `The \\`namespace\\` parameter passed to createNodeId must be a String (got ${typeof namespace})`\n    )\n  }\n\n  let nsHash = unprefixedCache.get(namespace)\n  if (!nsHash) {\n    nsHash = uuidv5(namespace, seedConstant) as string\n    unprefixedCache.set(namespace, nsHash)\n  }\n\n  // Calling uuid is relatively expensive because it calls into crypto for sha1.\n  // We use a local map to cache calls with the same ns+id pair, which helps a lot.\n  let nsCache = namespacedCache.get(namespace)\n  if (!nsCache) {","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/gatsbyjs/gatsby/blob/8b06340921ffdf23125a365b9c9923690cb62ce6/packages/gatsby/src/utils/create-node-id.ts#L22-L58","documentation":"createNodeId generates deterministic UUIDs from an input id and a namespace. The id parameter must be a string or number (numbers are coerced to strings). If it is any other type (object, undefined, null, boolean, array), Gatsby panics because the UUID generation cannot produce a deterministic hash.","triggerScenarios":"Calling createNodeId(undefined, 'namespace') or createNodeId({ id: 1 }, 'namespace') -- passing a non-string/non-number first argument. Typically inside sourceNodes, onCreateNode, or a source plugin where the id comes from upstream data that is unexpectedly undefined or an object.","commonSituations":"A source plugin fetches data where a record's primary key is null or missing, and that field is passed to createNodeId. A gatsby-node.js bug where a variable used as id is undefined due to a typo or missing data path. Passing an object instead of object.id.","solutions":["Ensure the first argument to createNodeId is always a string or number -- check the data source for null/undefined keys.","Add a guard: createNodeId(String(record.id || record.slug || fallback), 'namespace').","Log the value before calling createNodeId to identify which record produces the bad id.","Fix upstream data fetching to always provide a valid identifier."],"exampleFix":"// before\nconst nodeId = createNodeId(data.maybeId, 'my-plugin')\n\n// after\nif (!data.id) {\n  reporter.warn(`Record missing id: ${JSON.stringify(data)}`)\n  return\n}\nconst nodeId = createNodeId(data.id, 'my-plugin')","handlingStrategy":"validation","validationCode":"// Validate id before calling createNodeId\nfunction validateCreateNodeIdInput(id) {\n  if (typeof id !== 'string' && typeof id !== 'number') {\n    throw new Error('createNodeId requires string or number, got ' + typeof id)\n  }\n}\n\nvalidateCreateNodeIdInput(record.id)","typeGuard":"// Type guard for valid createNodeId id parameter\nfunction isValidNodeId(id) {\n  return typeof id === 'string' || typeof id === 'number'\n}\n\nif (!isValidNodeId(record.id)) {\n  reporter.warn('Skipping node: invalid id type ' + typeof record.id)\n  return\n}\nvar nodeId = createNodeId(record.id, 'my-plugin')","tryCatchPattern":null,"preventionTips":["Always validate that the id from upstream data is a string or number before calling createNodeId.","Filter or skip records with missing/null primary keys.","Log records that fail validation to identify data quality issues."],"tags":["createnodeid","source-plugin","validation","nodes"],"backgroundTag":null,"analyzedSha":"8b06340921ffdf23125a365b9c9923690cb62ce6","analyzedAt":"2026-08-13T02:36:21.405Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}