Google-cloud-node: 403 forbidden error on a bucket I am not touching

Created on 15 Sep 2017  路  2Comments  路  Source: googleapis/google-cloud-node

Environment details

  • OS: OSX 10.12.6
  • Node.js version: 7.8.0
  • npm version: 4.2.0
  • @ google-cloud/storage version 1.2.1

What is going on?

I am writing a build script that uploads my application .dmg to GCS.

Unfortunately I am running into a weird situation where I get a 403 forbidden error, but that error mentions a bucket that is not the bucket I am uploading to.

This only happens with one particular file name: Cicerone-v0.6.0-mac-x64.dmg.

With every other file I tried it works fine:

  • uploading Cicerone-v0.6.0-mac-x64-test.dmg to cc-installers works fine. Re-uploading (overwriting) works too.
  • uploading Cicerone-v0.6.0-mac-x64-test.dmg to cc-installers-2 (note the -2) works fine. Re-uploading (overwriting) works too.
  • However uploading Cicerone-v0.6.0-mac-x64.dmg to cc-installers-2 results in the 403 pasted below. Notice the bucket name?!?
{ errors: 
   [ { domain: 'global',
       reason: 'forbidden',
       message: '[email protected] does not have storage.objects.delete access to bucket cc-installers.' } ],
  code: 403,
  message: '[email protected] does not have storage.objects.delete access to bucket cc-installers.' }

I am completely baffled here. Why am I getting an error about a bucket I am not even touching? And why does this happen on just this one file name? I tried this multiple times over two days to see if it was a fluke but it seems not.

Here is the relevant part of my build script:

const bucket = GCS.bucket( 'cc-installers-2' );
const gcs_file = bucket.file( file_name );

fs.createReadStream( file_path )
    .pipe( gcs_file.createWriteStream() )
    .on( 'error', function(err) { console.log( err ); } )
    .on( 'finish', function() {
        // The file upload is complete.
        console.log( 'file upload complete.' );
        done( true );
    });

I suspect you won't be able to reproduce this but any help in figuring out a fix would be appreciated. Thanks!

storage

Most helpful comment

I have a feeling this is due to an issue in gcs-resumable-upload, the module behind this method. There is a PR with a fix: https://github.com/stephenplusplus/gcs-resumable-upload/pull/23

In the meantime, you could try:

  • Disabling resumable uploads: gcs_file.createWriteStream({ resumable: false })
  • Deleting the cache file that gcs-resumable-upload uses to track the state of uploads: ~/.config/configstore/gcs-resumable-upload.json

If neither of these work, we likely have a different problem on our hands. Let me know, and sorry you ran into this!

All 2 comments

I have a feeling this is due to an issue in gcs-resumable-upload, the module behind this method. There is a PR with a fix: https://github.com/stephenplusplus/gcs-resumable-upload/pull/23

In the meantime, you could try:

  • Disabling resumable uploads: gcs_file.createWriteStream({ resumable: false })
  • Deleting the cache file that gcs-resumable-upload uses to track the state of uploads: ~/.config/configstore/gcs-resumable-upload.json

If neither of these work, we likely have a different problem on our hands. Let me know, and sorry you ran into this!

Aha! I was wondering if gcs was caching anything locally. It sure felt like that kind of bug, but I couldn't find any info about a cache in the docs.

There was indeed an entry in gcs-resumable-upload.json for that problematic file. I trashed the file and now everything works swimmingly.

That's a lot of hours spent on bad cached data 馃槬. I wonder if docs and/or error messages could include some info about the cache so that others might get to their solution faster.

In any case thank-you @stephenplusplus !

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chadbr picture chadbr  路  3Comments

stephenplusplus picture stephenplusplus  路  3Comments

bamapookie picture bamapookie  路  5Comments

VikramTiwari picture VikramTiwari  路  3Comments

ddunkin picture ddunkin  路  3Comments