Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Storage non-resumable uploads fail #2050

Closed
ddunkin opened this issue Mar 5, 2017 · 3 comments
Closed

Storage non-resumable uploads fail #2050

ddunkin opened this issue Mar 5, 2017 · 3 comments
Assignees
Labels
api: storage Issues related to the Cloud Storage API. core type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@ddunkin
Copy link

ddunkin commented Mar 5, 2017

Storage non-resumable uploads fail when used with @google-cloud/common 0.12.1. The error message is:

UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Sorry, we cannot connect to Cloud Services without a project ID. You may specify one with an environment variable named "GCLOUD_PROJECT". See https://googlecloudplatform.github.io/google-cloud-node/#/docs/guides/authentication for a detailed guide on creating an authenticated connection.

The error message is misleading. The code mistakenly assumes any error thrown util.makeAuthenticatedRequestFactory -> makeAuthenticatedRequest -> onAuthenticated is because of a missing project ID.

The bug that causes the error was introduced by #1990. hasOwnProperty is called on an object that does not have that function. An alternative implementation would be to call Object.hasOwnProperty.call(value, opt) instead of value.hasOwnProperty(opt).

Environment details

  • OS: macOS, Linux
  • Node.js version: 6.x
  • npm version: 3.x
  • google-cloud-node version: 0.47.0

Steps to reproduce

  1. require google-cloud
  2. storage.bucket('my-bucket').upload('file.txt', { resumable: false })
@stephenplusplus stephenplusplus added api: storage Issues related to the Cloud Storage API. core type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Mar 6, 2017
@stephenplusplus
Copy link
Contributor

Thank you for catching this and debugging it! I just put through a fix: a1edaab -- does this look good?

@andrewolobo
Copy link

This bug is still active. google-cloud-node version:"0.7.0", default storage.bucket('my-bucket').upload('file.txt') does not upload .Must explicitly add resumable flag for upload storage.bucket('my-bucket').upload('file.txt', { resumable: true }) .

@stephenplusplus
Copy link
Contributor

This code works for me with @google-cloud/storage@0.7.0:

var storage = require('@google-cloud/storage')()
var bucket = storage.bucket('stephen-has-a-new-bucket')

bucket.upload('package.json', console.log) // no error

Can you make sure you rm -rf node_modules && npm install --save @google-cloud/storage@^0.7.0 and let me know if it persists? If you can, a reproducible test gist that I can clone, install, and run to see the crash would help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: storage Issues related to the Cloud Storage API. core type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

3 participants