{"action":"created","issue":{"url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-node/issues/1654","repository_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-node","labels_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-node/issues/1654/labels{/name}","comments_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-node/issues/1654/comments","events_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-node/issues/1654/events","html_url":"https://github.com/GoogleCloudPlatform/google-cloud-node/issues/1654","id":180223835,"number":1654,"title":"Scoping error in packages/common/src/util.js","user":{"login":"abawany","id":821103,"avatar_url":"https://avatars.githubusercontent.com/u/821103?v=3","gravatar_id":"","url":"https://api.github.com/users/abawany","html_url":"https://github.com/abawany","followers_url":"https://api.github.com/users/abawany/followers","following_url":"https://api.github.com/users/abawany/following{/other_user}","gists_url":"https://api.github.com/users/abawany/gists{/gist_id}","starred_url":"https://api.github.com/users/abawany/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abawany/subscriptions","organizations_url":"https://api.github.com/users/abawany/orgs","repos_url":"https://api.github.com/users/abawany/repos","events_url":"https://api.github.com/users/abawany/events{/privacy}","received_events_url":"https://api.github.com/users/abawany/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-node/labels/bug","name":"bug","color":"fc2929"},{"url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-node/labels/storage","name":"storage","color":"fad8c7"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-09-30T05:37:12Z","updated_at":"2016-09-30T13:21:44Z","closed_at":null,"body":"When Google Storage is used to access a file that does not exist, the following uncaught exception is generated by the package:\r\n\r\n```\r\nerror:  ApiError: Not Found\r\n    at new util.ApiError (/tmp/node_modules/google-cloud/node_modules/@google-cloud/common/src/util.js:107:10)\r\n    at Object.parseHttpRespMessage (/tmp/node_modules/google-cloud/node_modules/@google-cloud/common/src/util.js:149:33)\r\n    at Object.handleResp (/tmp/node_modules/google-cloud/node_modules/@google-cloud/common/src/util.js:124:18)\r\n    at .<anonymous> (/tmp/node_modules/google-cloud/node_modules/@google-cloud/storage/src/file.js:632:21)\r\n    at emitOne (events.js:96:13)\r\n    at emit (events.js:188:7)\r\n    at emitOne (events.js:96:13)\r\n    at DestroyableTransform.emit (events.js:188:7)\r\n    at emitOne (events.js:96:13)\r\n    at Request.emit (events.js:188:7)\r\n```\r\n\r\nGoing to line 107 of the offending file shows this:\r\n```\r\n106: util.ApiError = function(errorBody) {\r\n107:  return new ApiError(errorBody);\r\n108: };\r\n```\r\n\r\n(EDIT: alleged remedy was not a solution either). ApiError is defined above this code as `var ApiError = ...`. \r\n\r\n#### Environment details\r\n\r\n  - OS: OSX\r\n  - Node.js version: 6.2.1\r\n  - npm version: 3.9.3\r\n  - google-cloud-node version: 0.41.2\r\n\r\n#### Steps to reproduce\r\n\r\n  1. require `google-cloud`\r\n  2. use the storage module to access a non-existent file in a GS bucket\r\n\r\nMaking sure to follow these steps will guarantee the quickest resolution possible.\r\n\r\nThanks!\r\n"},"comment":{"url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-node/issues/comments/250742733","html_url":"https://github.com/GoogleCloudPlatform/google-cloud-node/issues/1654#issuecomment-250742733","issue_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-node/issues/1654","id":250742733,"user":{"login":"abawany","id":821103,"avatar_url":"https://avatars.githubusercontent.com/u/821103?v=3","gravatar_id":"","url":"https://api.github.com/users/abawany","html_url":"https://github.com/abawany","followers_url":"https://api.github.com/users/abawany/followers","following_url":"https://api.github.com/users/abawany/following{/other_user}","gists_url":"https://api.github.com/users/abawany/gists{/gist_id}","starred_url":"https://api.github.com/users/abawany/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abawany/subscriptions","organizations_url":"https://api.github.com/users/abawany/orgs","repos_url":"https://api.github.com/users/abawany/repos","events_url":"https://api.github.com/users/abawany/events{/privacy}","received_events_url":"https://api.github.com/users/abawany/received_events","type":"User","site_admin":false},"created_at":"2016-09-30T13:21:44Z","updated_at":"2016-09-30T13:21:44Z","body":"Sure. I was previously using `gcloud@0.37.0` and hadn't noticed these issues. Moving to `google-cloud` (starting with 0.40.0 and now at 0.41.2) shows these issues.\r\n\r\n```\r\nvar gc = require('google-cloud') ({ projectId: 'something' });\r\nvar gsInst = gc.storage({ projectId: 'something' });\r\nvar bucket = gsInst.bucket('bucket');\r\nvar destFile = bucket.file(fromFile);\r\nvar strm = destFile.createReadStream({validation: 'crc32c'});\r\nstrm\r\n  .on('error', function(e) { \r\n    log.inst.error({e: e.stack});\r\n    return cb(e); \r\n  })\r\n  .pipe(res)\r\n  .on('response', function(r) { log.inst.debug({r: r}); })\r\n  .on('end', function() { \r\n    log.inst.debug({end: true}); \r\n    return res.send(200); \r\n  }\r\n);\r\n```\r\n"}}
{"actor":{"display_login":"abawany"}}