grpc / grpc

The C based gRPC (C++, Python, Ruby, Objective-C, PHP, C#)

Home Page:https://grpc.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Client streams crashes with wrong number of arguments

Loschcode opened this issue · comments

What version of gRPC and what language are you using?

Ruby 2.7.5 / gRPC 1.46.2

What operating system (Linux, Windows,...) and version?

MacOS

What runtime / compiler are you using (e.g. python version or version of gcc)

Ruby 2.7.5

What did you do?

syntax = "proto3";

package rpc.backend;

option ruby_package = "Rpc::Backend";

service RolesAndPermissions {
    rpc CheckHighestRole(stream CheckRoleReq) returns (CheckRoleResp) {}
}

message CheckRoleReq {
    string identity_id = 1;
    string scope_id = 2;
    string scope = 3;
}

message CheckRoleResp {
    string identity_id = 1;
    string scope_id = 2;
    string scope = 3;
    string role = 4;
    int32 level = 5;
}

I've generated the Ruby from grpc_tools_ruby_protoc

stub = Rpc::Backend::RolesAndPermissions::Stub.new("0.0.0.0:10541", :this_channel_is_insecure)
requests = [
  Rpc::Backend::CheckRoleReq.new(identity_id: "caab41d7-c119-421a-a457-7d4f387e8029", scope_id: "", scope: ""),
  Rpc::Backend::CheckRoleReq.new(identity_id: "another-id", scope_id: "", scope: "")
]

stub.check_highest_role(requests)

What did you expect to see?

A working client stream being sent to the gRPC server

What did you see instead?

GRPC::Unknown: 2:ArgumentError: wrong number of arguments (given 1, expected 2). debug_error_string:{"created":"@1654801454.657498000","description":"Error received from peer ipv4:0.0.0.0:10541","file":"src/core/lib/surface/call.cc","file_line":953,"grpc_message":"ArgumentError: wrong number of arguments (given 1, expected 2)","grpc_status":2}
from /Users/loschcode/Desktop/work/livestorm/livestorm-app/packages/backend/vendor/bundle/ruby/2.7.0/gems/grpc-1.46.2/src/ruby/lib/grpc/generic/active_call.rb:29:in `check_status'

Anything else we should know about your project / environment?

It doesn't use any layer on top of the grpc library. Bidi and server streams are working fine, it's specific to client streams.

At the end it was a problem of argument in the Service on the server side

class RolesAndPermissionsListener < ::Rpc::Backend::RolesAndPermissions::Service
  def check_highest_role(message, metadata = {}) # <- this part was `metadata` originally, and was crashing
    ...

    Rpc::Backend::CheckRoleResp.new(
      identity_id: identity_id,
      scope_id: scope_id,
      scope: scope,
      role: 'speaker',
      level: 5
    )
  end
end