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:
Cicerone-v0.6.0-mac-x64-test.dmg to cc-installers works fine. Re-uploading (overwriting) works too.Cicerone-v0.6.0-mac-x64-test.dmg to cc-installers-2 (note the -2) works fine. Re-uploading (overwriting) works too.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!
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:
gcs_file.createWriteStream({ resumable: false })~/.config/configstore/gcs-resumable-upload.jsonIf 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 !
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/23In the meantime, you could try:
gcs_file.createWriteStream({ resumable: false })~/.config/configstore/gcs-resumable-upload.jsonIf neither of these work, we likely have a different problem on our hands. Let me know, and sorry you ran into this!