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

Fix calling gRPC stub if proto-scheme contains nested enum #27

Merged

Conversation

ashashev
Copy link
Contributor

Problem

Calling of gRPC stub fails if the stub contains proto-scheme with nested enum. Regardless of whether message with the nested enum is used or not.

Steps to reproduce bugs

The following proto-file occurs the problem.

syntax = "proto3";
                                                                    
message Request {
    string text = 1;
}

message Response {
    enum Code {
      OK = 0;
      FAIL = 1;
    } 
    optional Code code = 1;
}                  
                                                                              
service Service { 
    rpc Call (Request) returns (Response);
}

Creating service:

curl -X POST -d '{"suffix":"first", "name":"first"}' http://localhost:8228/api/internal/mockingbird/v2/service

Creating a stub using the prototype above:

curl -i -X POST localhost:8228/api/internal/mockingbird/v2/grpcStub -d \
'{
  "name": "GRPC ***",
  "labels": [],
  "scope": "persistent",
  "methodName": "Service/Call",
  "requestCodecs": "c3ludGF4ID0gInByb3RvMyI7CgptZXNzYWdlIFJlcXVlc3QgewogICAgc3RyaW5nIHRleHQgPSAxOwp9CgptZXNzYWdlIFJlc3BvbnNlIHsKICAgIGVudW0gQ29kZSB7CiAgICAgIE9LID0gMDsKICAgICAgRkFJTCA9IDE7CiAgICB9CiAgICBvcHRpb25hbCBDb2RlIGNvZGUgPSAxOwp9CgpzZXJ2aWNlIFNlcnZpY2UgewogICAgcnBjIENhbGwgKFJlcXVlc3QpIHJldHVybnMgKFJlc3BvbnNlKTsKfQo=",
  "requestClass": "Request",
  "requestPredicates": {},
  "responseCodecs": "c3ludGF4ID0gInByb3RvMyI7CgptZXNzYWdlIFJlcXVlc3QgewogICAgc3RyaW5nIHRleHQgPSAxOwp9CgptZXNzYWdlIFJlc3BvbnNlIHsKICAgIGVudW0gQ29kZSB7CiAgICAgIE9LID0gMDsKICAgICAgRkFJTCA9IDE7CiAgICB9CiAgICBvcHRpb25hbCBDb2RlIGNvZGUgPSAxOwp9CgpzZXJ2aWNlIFNlcnZpY2UgewogICAgcnBjIENhbGwgKFJlcXVlc3QpIHJldHVybnMgKFJlc3BvbnNlKTsKfQo=",
  "responseClass": "Response",
  "response": {
    "mode": "fill",
    "data": {
      "code": "OK"
    }
  },
  "state": null,
  "seed": null,
  "service": "first"
}' \

Calling the stub:

grpcurl \
  -proto bad.proto \
  -d '{
  "text": "qwe123"
}' \
  -plaintext localhost:9000 \
  'Service/Call'

The expected result of this call, it is successful and returns { "code": "OK" }, but in reality it returns an error.

@mockingbird/maintainers

Calling of gRPC stub fails if the stub contains proto-scheme with nested
enum. Regardless of whether message with the nested enum is used or not.
@danslapman danslapman merged commit 96f3a7d into leviysoft:main Nov 25, 2023
6 checks passed
@ashashev ashashev deleted the fix/call-grpc-stub-with-nested-enum branch November 25, 2023 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants