Skip to content

Commit

Permalink
chore(storage): fix Object Read not exist error (#6648)
Browse files Browse the repository at this point in the history
Ensures that when using gRPC an attempt to read an object that does not exist returns the `ErrObjectNotExist` error, like it does in HTTP.
  • Loading branch information
noahdietz committed Sep 12, 2022
1 parent e535dc7 commit 5de75dd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions storage/grpc_client.go
Expand Up @@ -893,6 +893,11 @@ func (c *grpcStorageClient) NewRangeReader(ctx context.Context, params *newRange
}

msg, err = stream.Recv()
// These types of errors show up on the Recv call, rather than the
// initialization of the stream via ReadObject above.
if s, ok := status.FromError(err); ok && s.Code() == codes.NotFound {
return ErrObjectNotExist
}

return err
}, s.retry, s.idempotent, setRetryHeaderGRPC(ctx))
Expand Down
10 changes: 10 additions & 0 deletions storage/integration_test.go
Expand Up @@ -2696,6 +2696,16 @@ func TestIntegration_Encryption(t *testing.T) {
}
}

func TestIntegration_NonexistentObjectRead(t *testing.T) {
t.Parallel()
multiTransportTest(context.Background(), t, func(t *testing.T, ctx context.Context, bucket, _ string, client *Client) {
_, err := client.Bucket(bucket).Object("object-does-not-exist").NewReader(ctx)
if !errors.Is(err, ErrObjectNotExist) {
t.Errorf("Objects: got %v, want ErrObjectNotExist", err)
}
})
}

func TestIntegration_NonexistentBucket(t *testing.T) {
t.Parallel()
ctx := context.Background()
Expand Down

0 comments on commit 5de75dd

Please sign in to comment.