Skip to content

storage: 1.51.0 regression, the Exists method returns an error when the object doesn't exist #11845

@appaquet

Description

@appaquet

Client

storage

Environment

go version go1.23.7 linux/amd64

Code and Dependencies

package main

import (
	"context"

	"gocloud.dev/blob"

	_ "gocloud.dev/blob/gcsblob"
)

func main() {
	ctx := context.Background()
	bucket, err := blob.OpenBucket(ctx, "gs://my-bucket")
	if err != nil {
		panic(err)
	}

	exists, err := bucket.Exists(ctx, "valid.tar.gz")
	if err != nil {
		panic(err)
	}
	if !exists {
		panic("the file should have existed")
	}

	exists, err = bucket.Exists(ctx, "invalid.tar.gz")
	if err != nil {
		panic(err)
	}
	if exists {
		panic("the file should not have existed")
	}
}
go.mod
module modname

go 1.24.0

require (
    ...
	cloud.google.com/go/storage v1.51.0
    gocloud.dev v0.40.0
    ...
)

Expected behavior

The Exists method should return false if the object doesn't exist instead of an error.

Actual behavior

The method returns an error instead.

panic: blob (key "invalid.tar.gz") (code=Unknown): storage: object doesn't exist: googleapi: Error 404: No such object: my-bucket/invalid.tar.gz, notFound

Additional context

This is a regression from 1.51.0 and works in 1.50.0.

Metadata

Metadata

Assignees

Labels

api: storageIssues related to the Cloud Storage API.type: questionRequest for information or clarification. Not an issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions