SebastianStehle
SebastianStehle

Reputation: 2459

Copy objects in google cloud objects started to fail

I have a class that copies objects in google cloud storage and suddenly stopped working yesterday.

It looks like a client error, but I have absolute no idea what the issue could be.

Attached you will find the screenshot with all relevant information. It is from an integration test that tests the abstraction to google cloud storage.

My sample to reproduce it: https://gist.github.com/SebastianStehle/ff8315f724f14c3e805e8986eff0f1ad

An even simpler sample to reproduce it:

using Google.Cloud.Storage.V1;
using System;
using System.IO;

namespace GCETest
{
    public class Program
    {
        public  static void Main(string[] args)
        {
            var bucket = "squidex-test";
            var objectStream = new MemoryStream(new byte[] { 0x1, 0x2, 0x3, 0x4 });
            var objectName = Guid.NewGuid().ToString();

            var storageClient = StorageClient.Create();

            storageClient.UploadObject(bucket, objectName, "application/octet-stream", objectStream);
            storageClient.CopyObject(bucket, objectName, bucket, $"{objectName}_Copy");
        }
    }
}

The full exception:

The service storage has thrown an exception: Google.GoogleApiException: Google.Apis.Requests.RequestError
Invalid argument [400]
Errors [
    Message[Invalid argument] Location[ - ] Reason[invalid] Domain[global]
]

   at Google.Apis.Requests.ClientServiceRequest`1.Execute()
   at Google.Cloud.Storage.V1.StorageClientImpl.CopyObject(String sourceBucket, String sourceObjectName, String destinationBucket, String destinationObjectName, CopyObjectOptions options)
   at GCETest.Program.Main(String[] args) in C:\Users\mail2\source\repos\AzureTest\AzureTest\Program.cs:line 18

It started yesterday, I think, and has always happened since then and not only on this bucket.

Copy

Upvotes: 1

Views: 351

Answers (1)

Jon Skeet
Jon Skeet

Reputation: 1500135

This was a bug in the client library, in terms of its handling of the RewriteToken part of the RewriteObjectResponse. We were assuming it would not be set when the operation was complete, and it appears that recently it started being set to an empty string instead.

We have fixed the code to use the Done property instead, and released two new versions of the Google.Cloud.Storage.V1 package:

  • Version 2.3.0-beta04 is the latest prerelease package
  • Version 2.2.1 is available for users who need to stay on GA versions

Upvotes: 4

Related Questions