diff --git a/internal/pkg/gateway/commitstatus.go b/internal/pkg/gateway/commitstatus.go index 211be09f33b..7396ea2fd6d 100644 --- a/internal/pkg/gateway/commitstatus.go +++ b/internal/pkg/gateway/commitstatus.go @@ -33,6 +33,16 @@ func (gs *Server) CommitStatus(ctx context.Context, signedRequest *gp.SignedComm return nil, status.Errorf(codes.InvalidArgument, "invalid status request: %v", err) } + // Validate the request has valid channel id and transaction id + switch { + case request.GetIdentity() == nil: + return nil, status.Error(codes.InvalidArgument, "no identity provided") + case request.GetChannelId() == "": + return nil, status.Error(codes.InvalidArgument, "no channel ID provided") + case request.GetTransactionId() == "": + return nil, status.Error(codes.InvalidArgument, "transaction ID should not be empty") + } + signedData := &protoutil.SignedData{ Data: signedRequest.GetRequest(), Identity: request.GetIdentity(), diff --git a/internal/pkg/gateway/commitstatus_test.go b/internal/pkg/gateway/commitstatus_test.go index c84c67916ef..c37211cd2fc 100644 --- a/internal/pkg/gateway/commitstatus_test.go +++ b/internal/pkg/gateway/commitstatus_test.go @@ -119,7 +119,7 @@ func TestCommitStatus(t *testing.T) { request := &pb.CommitStatusRequest{ ChannelId: testChannel, - Identity: tt.identity, + Identity: []byte("IDENTITY"), TransactionId: "TX_ID", } requestBytes, err := proto.Marshal(request)