这是indexloc提供的服务,不要输入任何密码
Skip to content

storage: ErrObjectNotExist isn't returning while using CopierFrom. #10760

@nalkhovikleverx

Description

@nalkhovikleverx

Client

golang google cloud storage

Environment

Alpine Docker on GKE
go version go1.22.6 linux/amd64

Code and Dependencies

func (c *gcs) CopyObject(ctx context.Context, cmd CopyObjectCommand) (*storage.ObjectAttrs, error) {
	bucket := c.client.Bucket(cmd.Bucket)

	objAttr, err := bucket.Object(cmd.DestinationPath).CopierFrom(bucket.Object(cmd.SourcePath)).Run(ctx)
	if err != nil {
		if errors.Is(err, storage.ErrObjectNotExist) {
			return nil, application.ErrObjectNotExist
		}
	}

Client created like this:

	storageClient, err := storage.NewClient(ctx, option.WithTelemetryDisabled())
	if err != nil {
		return fmt.Errorf("failed to create storage client: %w", err)
	}
	storageClient.SetRetry(
		storage.WithBackoff(gax.Backoff{
			Initial:    cfg.StorageClient.InitialRetryDelay,
			Max:        cfg.StorageClient.MaxRetryDelay,
			Multiplier: cfg.StorageClient.RetryBackoffMultiplier,
		}),
		storage.WithPolicy(storage.RetryAlways),
	)
}
go.mod
module mymodule

go 1.22

require (
	cloud.google.com/go/storage v1.43.0
)

Expected behavior

When I call this function with not existed file I expect that the storage.ErrObjectNotExist returned.

Actual behavior

When I call this function with not existed file, I got the *googleapi.Error instance.

Metadata

Metadata

Assignees

Labels

api: storageIssues related to the Cloud Storage API.priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions