go-cloud icon indicating copy to clipboard operation
go-cloud copied to clipboard

writer.Close() failed and return PermissionDenied error

Open gobylor opened this issue 4 years ago • 1 comments

writer.Close()

Close writer failed.

error: code=PermissionDenied): gocloud.dev/blob.(*Writer).Close /go/pkg/mod/[email protected]/blob/blob.go:341

  • googleapi: Error 403: [email protected] does not have storage.objects.delete access to the Google Cloud Storage object., forbidden"

gobylor avatar Nov 16 '22 03:11 gobylor

This is working as intended and expected.

Per https://pkg.go.dev/gocloud.dev/blob#Writer.Close, Close closes the blob writer. The write operation is not guaranteed to have succeeded until Close returns with no error.

In this case, it looks like you are trying to write on top of an existing blob, and GCS requires the storage.objects.delete permission to do that (https://stackoverflow.com/q/66129154), which makes sense.

vangent avatar Nov 16 '22 04:11 vangent