Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gRPC service function with caller param validates incorrectly. #1317

Closed
daneshk opened this issue May 4, 2021 · 1 comment · Fixed by ballerina-platform/module-ballerina-grpc#218
Assignees
Labels
module/grpc Team/DIU Data, IO, and Util packages related issues Type/Bug

Comments

@daneshk
Copy link
Member

daneshk commented May 4, 2021

Description:
Below is the proto definition,

syntax = "proto3";
import "google/protobuf/wrappers.proto";
 
service StreamingCalcService {
   rpc sum(stream google.protobuf.Int64Value) returns (google.protobuf.Int64Value);
   rpc incrementalSum(stream google.protobuf.Int64Value) returns (stream google.protobuf.Int64Value);
}

Below is the service implementation,

import ballerina/grpc;

listener grpc:Listener ep = new (9090);

@grpc:ServiceDescriptor {
    descriptor: ROOT_DESCRIPTOR,
    descMap: getDescriptorMap()
}
service "StreamingCalcService" on ep {
    
    remote function sum(stream<int, grpc:Error?> clientStream) returns int|error {
       int sum = 0;
       error? e = clientStream.forEach(function (int value) {
           sum += value;
       });
       return sum;
    }
    remote function incrementalSum(StreamingCalcServiceIntCaller caller, stream<int, grpc:Error?> clientStream) returns error? {
       int sum = 0;
       error? e = clientStream.forEach(function (int value) {
           sum += value;
           checkpanic caller->sendInt(sum);
       });
       check caller->complete();
    }
}

The build is failing giving the following error,

ERROR [StreamingCalcService_sample_service.bal:(18:5,25:6)] expected caller type "StreamingCalcServiceStreamintgrpcErrorCaller" but found "StreamingCalcServiceIntCaller"
error: compilation contains errors

but the correct caller is passed in service implementation.

Affected Versions:
slalpha5

@daneshk daneshk added this to the Swan Lake Beta1 milestone May 4, 2021
@Maninda Maninda added the Team/DIU Data, IO, and Util packages related issues label May 5, 2021
@daneshk
Copy link
Member Author

daneshk commented May 5, 2021

This is fixed in slalpha5. I tested in the wrong distribution. Now we are getting the following error

ERROR [StreamingCalcService_sample_service.bal:(18:5,25:6)] return types are not allowed with the caller

We need to allow only error? with the caller object

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module/grpc Team/DIU Data, IO, and Util packages related issues Type/Bug
Projects
None yet
2 participants