brandonmp / gatsby-source-google-sheets

A GatsbyJS plugin that pulls nodes from rows in a Google Sheet.
90 stars 32 forks source link

error thrown during sourceNode lifecycle: "TypeError: value must be an array of bytes" #26

Open city41 opened 5 years ago

city41 commented 5 years ago

When the spreadsheet has an id column, gatsby develop emits this error:

15:55 $ gatsby develop
success open and validate gatsby-configs - 0.012 s
success load plugins - 0.225 s
success onPreInit - 0.057 s
success initialize cache - 0.004 s
success copy gatsby files - 0.009 s
success onPreBootstrap - 0.006 s
FETCHING SHEET function fetchData(_x2, _x3, _x4) {
    return _ref.apply(this, arguments);
  }

 ERROR #11321  PLUGIN

"gatsby-source-google-sheets" threw an error while running the sourceNodes lifecycle:

value must be an array of bytes

  TypeError: value must be an array of bytes

  - v35.js:29 generateUUID
    [fgbg]/[uuid]/lib/v35.js:29:38

  - gatsby-node.js:45 
    [fgbg]/[gatsby-source-google-sheets]/gatsby-node.js:45:21

  - Array.forEach

  - gatsby-node.js:43 _callee$
    [fgbg]/[gatsby-source-google-sheets]/gatsby-node.js:43:18

  - next_tick.js:189 process._tickCallback
    internal/process/next_tick.js:189:7

warn The gatsby-source-google-sheets plugin has generated no Gatsby nodes. Do you need it?

This is because the row objects have an id property, and it looks like the id column in the spreadsheet clobbers it. Removing the id column (I just made my column name more specific, in my case level-id) fixes the issue.

If you want, I could send in a PR where detect the presence of an id column and fail with a more descriptive/helpful error.

Thanks for this cool plugin!