nteract / commuter

🚎 Notebook sharing hub
BSD 3-Clause "New" or "Revised" License
493 stars 66 forks source link

Unable to get GCS contents #286

Open rky0930 opened 4 years ago

rky0930 commented 4 years ago

Hi, I tried use commuter with GCS backend

I configured all enviroment variables below COMMUTER_STORAGE_BACKEND=gcs COMMUTER_BUCKET= COMMUTER_PORT=<4006> GOOGLE_APPLICATION_CREDENTIALS=

I got following error when i tried to get list of contents in my GCS bucket.

2020-04-20T17:59:54.69557274Z (node:1) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'prefixes' of undefined
2020-04-20T17:59:54.69559936Z     at cb (/usr/local/share/.config/yarn/global/node_modules/@nteract/commuter/lib/content-providers/gcs/gcs.js:82:15)
2020-04-20T17:59:54.69560896Z     at /usr/local/share/.config/yarn/global/node_modules/@google-cloud/storage/build/src/bucket.js:1408:17
2020-04-20T17:59:54.695617227Z     at onAuthenticated (/usr/local/share/.config/yarn/global/node_modules/@google-cloud/common/build/src/util.js:351:25)
2020-04-20T17:59:54.695625704Z     at /usr/local/share/.config/yarn/global/node_modules/@google-cloud/common/build/src/util.js:381:21
2020-04-20T17:59:54.695633587Z     at processTicksAndRejections (internal/process/task_queues.js:97:5)
2020-04-20T17:59:54.695641457Z (node:1) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 34)

my commuter version is

# npm show @nteract/commuter  version
5.10.0

Thanks

captainsafia commented 4 years ago

It looks like the error occurs here. We should update the if-statement to check if res existts.

if (res && res.prefixes) {...}

Would you be interested in submitting a contribution with this change?

aia commented 1 year ago

I run into this issue too. The solution is to set GOOGLE_CLOUD_PROJECT environment variable. GCP Node library requires GOOGLE_CLOUD_PROJECT and authentication is failing without it.