Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating a bucket returns 404 #1651

Open
airzym opened this issue Jun 21, 2024 · 1 comment
Open

Updating a bucket returns 404 #1651

airzym opened this issue Jun 21, 2024 · 1 comment

Comments

@airzym
Copy link

airzym commented Jun 21, 2024

I'm trying to create a bucket with versioning enabled.

I've followed Google Cloud documentation here, with the addition of creating the bucket, my code looks like the following:

public class LocalEmulatorStorageClientProvider : IStorageClientProvider
{
    public const string BucketName = "test-bucket";
    
    public async Task<StorageClient> CreateStorageClient()
    {
        var storageClient = await new StorageClientBuilder
        {
            BaseUri = "http://localhost:8083/storage/v1/",
            UnauthenticatedAccess = true,
        }.BuildAsync();

        if (!BucketExists(storageClient, BucketName))
        {
            await storageClient.CreateBucketAsync("test-project", BucketName);
            var bucket = await storageClient.GetBucketAsync(BucketName);
            bucket.Versioning = new Bucket.VersioningData
            {
                Enabled = true
            };
            await storageClient.UpdateBucketAsync(bucket);
        }
        
        return storageClient;
    }

    private bool BucketExists(StorageClient storageClient, string bucketName)
    {
        try
        {
            storageClient.GetBucket(bucketName);
            return true;
        }
        catch (Exception ex)
        {
            return false;
        }
    }
}

I'm running into a problem where the client throws when calling UpdateBucketAsync() with the following exception: The service storage has thrown an exception. HttpStatusCode is NotFound. Not Found which corresponds to the fake-gcs-server container logs:

2024-06-21 07:39:33 time=2024-06-21T06:39:33.521Z level=INFO msg="server started at http://0.0.0.0:8083"
2024-06-21 07:40:01 time=2024-06-21T06:40:01.553Z level=INFO msg="192.168.65.1 - - [21/Jun/2024:06:40:01 +0000] \"GET /storage/v1/b/test-bucket HTTP/1.1\" 404 119\n"
2024-06-21 07:40:14 time=2024-06-21T06:40:14.256Z level=INFO msg="192.168.65.1 - - [21/Jun/2024:06:40:14 +0000] \"POST /storage/v1/b?project=test-project HTTP/1.1\" 200 345\n"
2024-06-21 07:40:14 time=2024-06-21T06:40:14.291Z level=INFO msg="192.168.65.1 - - [21/Jun/2024:06:40:14 +0000] \"GET /storage/v1/b/test-bucket HTTP/1.1\" 200 345\n"
2024-06-21 07:40:35 time=2024-06-21T06:40:35.034Z level=INFO msg="192.168.65.1 - - [21/Jun/2024:06:40:35 +0000] \"PUT /storage/v1/b/test-bucket HTTP/1.1\" 404 119\n"

Theres nothing I can spot in the docs that suggest I'm missing something here.

@christophergunn
Copy link

It looks like your failing request is a PUT request to update a bucket. I'm no GoLang expert, but it seems that the code doesn't support PUT requests on that route:

server.go

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants