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

No such record error when having the generated stub file in a separate module #3655

Closed
dilanSachi opened this issue Nov 15, 2022 · 1 comment · Fixed by ballerina-platform/module-ballerina-grpc#1082
Assignees
Labels
module/grpc Reason/EngineeringMistake The issue occurred due to a mistake made in the past. Team/PCM Protocol connector packages related issues Type/Bug
Milestone

Comments

@dilanSachi
Copy link
Contributor

dilanSachi commented Nov 15, 2022

Description:
Consider the following proto

syntax = "proto3";
import "google/protobuf/wrappers.proto";
service HelloWorld {
	rpc hello (google.protobuf.StringValue) returns (ABC);
}

message ABC {
	string s = 1;
}

Generate the stub file for this and add to a separate module and publish it.
Import this in a new grpc service and use as follows.

import ballerina/grpc;
import ballerina/io;
import dilan/stub_module;

@grpc:Descriptor {
    value: stub_module:SIMPLE_RPC_DESC
}
service "HelloWorld" on new grpc:Listener(9090) {
    remote function hello(string request) returns stub_module:ABC {
    	io:println(request);
        return {};
    }
}

When bal run is executed, following error can be seen.
A workaround is to add |error to the function return type. --> remote function hello(string request) returns stub_module:ABC|error {

error: No such record: ABC
        at ballerina.grpc.1:externRegister(service_endpoint.bal:137)
           ballerina.grpc.1.Listener:attach(service_endpoint.bal:66)

This is due to some native logic issues when building the service registry
https://github.com/ballerina-platform/module-ballerina-grpc/blob/master/native/src/main/java/io/ballerina/stdlib/grpc/ServiceResource.java#L59

@github-actions
Copy link

This issue is NOT closed with a proper Reason/ label. Make sure to add proper reason label before closing. Please add or leave a comment with the proper reason label now.

      - Reason/EngineeringMistake - The issue occurred due to a mistake made in the past.
      - Reason/Regression - The issue has introduced a regression.
      - Reason/MultipleComponentInteraction - Issue occured due to interactions in multiple components.
      - Reason/Complex - Issue occurred due to complex scenario.
      - Reason/Invalid - Issue is invalid.
      - Reason/Other - None of the above cases.

@dilanSachi dilanSachi added the Reason/EngineeringMistake The issue occurred due to a mistake made in the past. label Nov 30, 2022
@dilanSachi dilanSachi added this to the 2201.2.4 milestone Dec 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module/grpc Reason/EngineeringMistake The issue occurred due to a mistake made in the past. Team/PCM Protocol connector packages related issues Type/Bug
Projects
None yet
1 participant