Google Drive Error : Cannot read properties of undefined (reading 'pipe')

Hi Everyone,
I am using the branch n8n AI and was developing a flow based on one template utilizing Google Drive
I connected my service account to the appropriate shared folder and I can see my documents no problems with that, but when I ran the node it crashed with this error

ERROR: Cannot read properties of undefined (reading ‘pipe’)

I saw many posts here but with different nodes, with a flexibility to add return statements in them (code) but not with this one here

ANy idea on how to debug this properly and fix this issue ?

Many thanks

Rad

Hi @Rad, I am so sorry you’re having trouble. I don’t have a service account ready yet but just gave this a go through OAuth2 just now, where the below workflow is running fine using the latest ai-beta image as of now:

Result:

Can you confirm if you’re also seeing this problem on your end when using OAuth2? If so, can you share your exact workflow please?

If this is working when using OAuth2, but fails with a service account even after pulling the latest ai-beta image and after sharing your folder/files with your service account, can you give me a quick shout so I can create a new service account for testing on my end?

Thank you so much!

Hi @MutedJam Thank you so much for getting back to me.
I was indeed connecting with Service Account (didnt’t work) I created a new credential based on OAuth and it did work perfectly
thank you so much
Rad

Hi! I had the same issue here… I can’t use the service connection to retrieve a file from Google Drive :confused:

Is this a bug? Am I triyng to use a wrong connection type?

Thanks a lot!

Hi @Pedro_Cernausan, this sounds likely, though I didn’t get to test this yet unfortunately. Any chance you can simply use OAuth2 here?

Ho @Pedro_Cernausan and @MutedJam i do confirm that was the issue
I reset the connection to be via OAuth and it worked just fine,
Rad

Hi @MutedJam ! Is possible use the OAuth2, but because the conection is out of my control (I need to get more privileges on company that I work), I prefer service connection…

When u can test, can u tell us about it?

Thanks a lot!

Hi @Pedro_Cernausan, thanks so much for clarifying. I have tested the service account authentication with the File → Download operation of the Google Drive node and did indeed encounter unexpected behaviour here. I have added these problems to our internal bug tracker for a closer look and a fix.

Hi! All works fine? :thinking:
Can u send your code to me see if I do a mistake here?

Thanks a lot!

All works fine? :thinking:

Unfortunately it’s broken for me as well. I do not have a workaround at the moment apart from using OAuth2, but we will of course update this thread once a fix for the service account functionality is available.

Ok! Sorry, fast read and bad understand. Thanks!

1 Like

Btw @Jon looked into this earlier today and found that version 1 of the Google Drive node seems to work fine with service accounts.

Perhaps you want to test this version of the node? You can copy the node from the below example workflow:

This works even with a service account for me:

1 Like

Just to add, I have also put in a PR to fix this which is currently being reviewed once that is complete it will be merged and available in a future release.

2 Likes

Hi guys, I am facing the similar issue. I am trying to get certain files from google drive into my workflow using service account.
I am shared the folder with the service account email.
Is it a bug or I am making any mistake?

TypeError: Cannot read properties of undefined (reading 'pipe')
    at /usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/BinaryData/utils.js:43:18
    at new Promise (<anonymous>)
    at toBuffer (/usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/BinaryData/utils.js:39:12)
    at BinaryDataService.toBuffer (/usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/BinaryData/BinaryData.service.js:101:37)
    at BinaryDataService.store (/usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/BinaryData/BinaryData.service.js:85:39)
    at setBinaryDataBuffer (/usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/NodeExecuteFunctions.js:713:73)
    at prepareBinaryData (/usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/NodeExecuteFunctions.js:818:12)
    at Object.prepareBinaryData (/usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/NodeExecuteFunctions.js:1830:66)
    at Object.execute (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Google/Drive/v2/actions/file/download.operation.js:213:64)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)

Hey @Rajan,

Welcome to the community :tada:

Thanks for the reminder on this one, While I put in the PR a test failed so I need to fix the test to get this working I will see if I can get this done before the release of 1.25.0 next week. The PR for reference is here: fix(Google Drive Node): Fix issue preventing service account from downloading files by Joffcom · Pull Request #7642 · n8n-io/n8n · GitHub

I have just merged the change for this so it should be available in 1.25.0 later this week.

1 Like

New version [email protected] got released which includes the GitHub PR 7642.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.