diff --git a/packages/gatsby-source-drupal/src/gatsby-node.js b/packages/gatsby-source-drupal/src/gatsby-node.js index 2703a0c5d92d6..53a77d41e5da9 100644 --- a/packages/gatsby-source-drupal/src/gatsby-node.js +++ b/packages/gatsby-source-drupal/src/gatsby-node.js @@ -146,6 +146,20 @@ exports.sourceNodes = async ( changesActivity.end() return } + + if (!action || !data) { + reporter.warn( + `The webhook body was malformed + +${JSON.stringify(webhookBody, null, 4)} + + ` + ) + + changesActivity.end() + return + } + if (action === `delete`) { let nodesToDelete = data if (!Array.isArray(data)) { diff --git a/packages/gatsby-source-drupal/src/utils.js b/packages/gatsby-source-drupal/src/utils.js index 8e8a42fced0ab..7cdd67ef4e928 100644 --- a/packages/gatsby-source-drupal/src/utils.js +++ b/packages/gatsby-source-drupal/src/utils.js @@ -196,6 +196,17 @@ const handleWebhookUpdate = async ( }, pluginOptions = {} ) => { + if (!nodeToUpdate || !nodeToUpdate.attributes) { + reporter.warn( + `The updated node was empty or is missing the required attributes field. The fact you're seeing this warning means there's probably a bug in how we're creating and processing updates from Drupal. + +${JSON.stringify(nodeToUpdate, null, 4)} + ` + ) + + return + } + const { createNode } = actions const newNode = nodeFromData(