diff --git a/internal/app/server/open_saves.go b/internal/app/server/open_saves.go index 544b8b8f..d9fe441d 100644 --- a/internal/app/server/open_saves.go +++ b/internal/app/server/open_saves.go @@ -463,7 +463,7 @@ func (s *openSavesServer) CreateChunkedBlob(ctx context.Context, req *pb.CreateC b := blobref.NewChunkedBlobRef(req.GetStoreKey(), req.GetRecordKey()) b, err := s.metaDB.InsertBlobRef(ctx, b) if err != nil { - log.Errorf("CreateChunkedBlob failed for record (%v), blob key (%v): %v", b.RecordKey, b.Key, err) + log.Errorf("CreateChunkedBlob failed for store (%v), record (%v): %v", req.GetStoreKey(), req.GetRecordKey(), err) return nil, err } return &pb.CreateChunkedBlobResponse{ diff --git a/internal/app/server/open_saves_test.go b/internal/app/server/open_saves_test.go index 84c901ed..f6729904 100644 --- a/internal/app/server/open_saves_test.go +++ b/internal/app/server/open_saves_test.go @@ -31,6 +31,8 @@ import ( "github.com/stretchr/testify/require" "google.golang.org/api/iterator" "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" "google.golang.org/grpc/test/bufconn" "google.golang.org/protobuf/types/known/timestamppb" ) @@ -855,3 +857,18 @@ func TestOpenSaves_QueryRecords_Tags(t *testing.T) { assert.Contains(t, resp.Records[0].Tags, "hello") } + +func TestOpenSaves_CreateChunkedBlobNonExistent(t *testing.T) { + ctx := context.Background() + _, listener := getOpenSavesServer(ctx, t, "gcp") + _, client := getTestClient(ctx, t, listener) + + // Non-existent record should fail with codes.FailedPrecondition + res, err := client.CreateChunkedBlob(ctx, &pb.CreateChunkedBlobRequest{ + StoreKey: uuid.NewString(), + RecordKey: uuid.NewString(), + ChunkSize: 0, + }) + assert.Nil(t, res) + assert.Equal(t, codes.FailedPrecondition, status.Code(err)) +}