{"record":{"id":"d418a2b6ef8e0179","repo":"gatsbyjs/gatsby","slug":"createnode-must-be-a-function-was-typeof-create","errorCode":null,"errorMessage":"createNode must be a function, was ${typeof createNode}","messagePattern":"createNode 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":138,"sourceCode":"  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}`)\n  }\n\n  if (!hash) {\n    hash = createContentDigest(buffer)\n  }","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/gatsbyjs/gatsby/blob/8b06340921ffdf23125a365b9c9923690cb62ce6/packages/gatsby-source-filesystem/src/create-file-node-from-buffer.js#L120-L156","documentation":"Thrown by createFileNodeFromBuffer when the createNode parameter is not a function. Like the createNodeId check, this validates that the Gatsby createNode action (used to add nodes to the data layer) is correctly passed as a callable function.","triggerScenarios":"typeof createNode !== 'function' because the caller passed the wrong value — e.g., a node object instead of the action function, or forgot to pass it entirely (undefined).","commonSituations":"A plugin calls createFileNodeFromBuffer without destructuring createNode from actions, passes createNode(payload) result instead of createNode itself, or names the variable differently.","solutions":["Pass the createNode action function from Gatsby's actions object.","Ensure you pass the function reference, not the result of calling it.","Verify the variable name in your destructuring matches the expected parameter.","Check that actions is the Gatsby actions object, not a custom object."],"exampleFix":"// before\nawait createFileNodeFromBuffer({ buffer, name: 'file', createNode: {} })\n// after\nawait createFileNodeFromBuffer({ buffer, name: 'file', createNode })\n// where createNode is from: const { createNode } = actions","handlingStrategy":"type-guard","validationCode":"// Ensure createNode is a function before calling\nif (typeof createNode !== 'function') {\n  throw new TypeError(`createNode must be a function, got ${typeof createNode}`)\n}","typeGuard":"const isCreateNode = (val: unknown): val is (node: unknown) => void =>\n  typeof val === 'function'","tryCatchPattern":null,"preventionTips":["Always destructure createNode from the Gatsby actions object.","Pass the action function reference, not a node payload.","Use TypeScript types matching Gatsby's Actions interface to catch errors 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"}