{"record":{"id":"3f0cdaa317e950ac","repo":"gatsbyjs/gatsby","slug":"createnodeid-must-be-a-function-was-typeof-crea","errorCode":null,"errorMessage":"createNodeId must be a function, was ${typeof createNodeId}","messagePattern":"createNodeId must be a function, was (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/gatsby-source-filesystem/src/create-file-node-from-buffer.js","lineNumber":133,"sourceCode":" * @param {CreateFileNodeFromBufferPayload} options\n * @return {Promise<Object>}                  Returns the created node\n */\nmodule.exports = ({\n  buffer,\n  hash,\n  cache,\n  createNode,\n  getCache,\n  parentNodeId = null,\n  createNodeId,\n  ext,\n  name,\n}) => {\n  // validation of the input\n  // without this it's notoriously easy to pass in the wrong `createNodeId`\n  // see gatsbyjs/gatsby#6643\n  if (typeof createNodeId !== `function`) {\n    throw new Error(\n      `createNodeId must be a function, was ${typeof createNodeId}`\n    )\n  }\n  if (typeof createNode !== `function`) {\n    throw new Error(`createNode must be a function, was ${typeof createNode}`)\n  }\n  if (typeof getCache === `function`) {\n    // use cache of this plugin and not cache of function caller\n    cache = getCache(`gatsby-source-filesystem`)\n  }\n  if (typeof cache !== `object`) {\n    throw new Error(\n      `Neither \"cache\" or \"getCache\" was passed. getCache must be function that return Gatsby cache, \"cache\" must be the Gatsby cache, was ${typeof cache}`\n    )\n  }\n\n  if (!buffer) {\n    return Promise.reject(`bad buffer: ${buffer}`)","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/gatsbyjs/gatsby/blob/8b06340921ffdf23125a365b9c9923690cb62ce6/packages/gatsby-source-filesystem/src/create-file-node-from-buffer.js#L115-L151","documentation":"Thrown by createFileNodeFromBuffer in gatsby-source-filesystem when the createNodeId parameter is not a function. This is a defensive validation — createNodeId must be a Gatsby-provided helper that generates deterministic node IDs. Passing anything else (string, undefined, object) breaks node creation.","triggerScenarios":"typeof createNodeId !== 'function' because the caller passed a string ID, undefined, or destructured incorrectly from the Gatsby API (e.g., forgot to pass it from actions/Helpers).","commonSituations":"A plugin or gatsby-node.js calls createFileNodeFromBuffer but passes a raw string instead of the createNodeId function from createNodeId helper, or destructures the wrong variable name.","solutions":["Pass the createNodeId function from the Gatsby Node API (destructured from the first argument or actions.createNodeId).","Ensure createNodeId is invoked at call-time: createNodeId('some-id'), not passed as a string.","Check the function signature matches the documented parameters.","Verify you're destructuring from the correct Gatsby helper object."],"exampleFix":"// before\nawait createFileNodeFromBuffer({ buffer, name: 'file', createNodeId: 'my-id' })\n// after\nawait createFileNodeFromBuffer({ buffer, name: 'file', createNodeId })\n// where createNodeId is from: const { createNodeId } = actions","handlingStrategy":"type-guard","validationCode":"// Ensure createNodeId is a function before calling\nif (typeof createNodeId !== 'function') {\n  throw new TypeError(`createNodeId must be a function, got ${typeof createNodeId}`)\n}","typeGuard":"const isCreateNodeId = (val: unknown): val is (id: string) => string =>\n  typeof val === 'function'","tryCatchPattern":null,"preventionTips":["Always destructure createNodeId from the Gatsby API helpers, not from a node object.","Pass the function reference, not a pre-computed string ID.","Add TypeScript types to catch misuse at compile time."],"tags":["gatsby","filesystem","validation","node-creation","api-misuse"],"backgroundTag":null,"analyzedSha":"8b06340921ffdf23125a365b9c9923690cb62ce6","analyzedAt":"2026-08-13T02:36:21.405Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}