ballerina-platform / ballerina-library

The Ballerina Library
https://ballerina.io/learn/api-docs/ballerina/
Apache License 2.0
136 stars 64 forks source link

Error is not descriptive enough to figure out errors in a grpc proto file #6665

Closed ThaminduDilshan closed 4 months ago

ThaminduDilshan commented 4 months ago

Description:

If there are errors in a gRPC proto file and we try to build the descriptor, it gives a build error with the following stack trace. However the error itself is not descriptive enough to narrow down the root cause.

SEVERE: An error occurred when generating the proto descriptor.
io.ballerina.protoc.protobuf.exception.CodeGeneratorException: Invalid command syntax. Stream closed
    at io.ballerina.protoc.protobuf.utils.BalFileGenerationUtils.handleProcessExecutionErrors(BalFileGenerationUtils.java:110)
    at io.ballerina.protoc.protobuf.utils.BalFileGenerationUtils.generateDescriptor(BalFileGenerationUtils.java:83)
    at io.ballerina.protoc.protobuf.cmd.DescriptorsGenerator.generateRootDescriptor(DescriptorsGenerator.java:148)
    at io.ballerina.protoc.protobuf.cmd.GrpcCmd.generateBalFile(GrpcCmd.java:251)
    at io.ballerina.protoc.protobuf.cmd.GrpcCmd.execute(GrpcCmd.java:165)
    at java.base/java.util.Optional.ifPresent(Optional.java:178)
    at io.ballerina.cli.launcher.Main.main(Main.java:58)
Caused by: java.io.IOException: Stream closed
    at java.base/java.io.BufferedInputStream.getBufIfOpen(BufferedInputStream.java:168)
    at java.base/java.io.BufferedInputStream.read(BufferedInputStream.java:334)
    at java.base/sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:270)
    at java.base/sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:313)
    at java.base/sun.nio.cs.StreamDecoder.read(StreamDecoder.java:188)
    at java.base/java.io.InputStreamReader.read(InputStreamReader.java:177)
    at java.base/java.io.BufferedReader.fill(BufferedReader.java:162)
    at java.base/java.io.BufferedReader.readLine(BufferedReader.java:329)
    at java.base/java.io.BufferedReader.readLine(BufferedReader.java:396)
    at io.ballerina.protoc.protobuf.utils.BalFileGenerationUtils.handleProcessExecutionErrors(BalFileGenerationUtils.java:105)
    ... 6 more

An error occurred when generating the proto descriptor. Invalid command syntax. Stream closed

Steps to reproduce:

  1. Create a proto file with the following content.

    syntax = "proto3";
    
    service Test {
        rpc chat (stream Chat) returns (stream Chat);
    }
    
    message Chat {
        string id = 1;
        string message = 2
    }
  2. Generate the proto descriptor. bal grpc --input test.proto --output stubs

Affected Versions:

OS, DB, other environment details and versions:

Related Issues (optional):

Suggested Labels (optional):

Suggested Assignees (optional):

dilanSachi commented 4 months ago

Duplicate of https://github.com/ballerina-platform/ballerina-library/issues/4656. Hence closing

github-actions[bot] commented 4 months ago

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.