arthurnn / arthurnn/twirp-ruby
Missing module name in _twirp generated code
- Dominant language
- Ruby
- Stars
- 163
- Forks
- 61
- PR merge metrics
- No merged PRs in 30d
Description
# When I generate code from two proto files
```proto
// data.proto
syntax = "proto3";
import "ok.proto";
service Data {
rpc create(SetDataRequest) returns (ok.Response);
}
message SetDataRequest {
string uuid = 1;
}
```
```proto
// ok.proto
syntax = "proto3";
package ok;
message Response { }
```
### With one protoc execute
```sh
protoc --proto_path=. --ruby_out=. --twirp_ruby_out=. --plugin=/Users/a.zimin/go/bin/protoc-gen-twirp_ruby data.proto ok.proto
```
### I have a code with a missing module name of Response class
```ruby
# data_twirp.rb
# Code generated by protoc-gen-twirp_ruby 1.4.1, DO NOT EDIT.
# ...SKIP...
rpc :create, SetDataRequest, Response, :ruby_method => :create
# ...SKIP...
```
```ruby
module Ok
Response = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("ok.Response").msgclass
end
```
### With two protoc calls
```sh
protoc --proto_path=. --ruby_out=. --twirp_ruby_out=. --plugin=/Users/a.zimin/go/bin/protoc-gen-twirp_ruby data.proto
protoc --proto_path=. --ruby_out=. --twirp_ruby_out=. --plugin=/Users/a.zimin/go/bin/protoc-gen-twirp_ruby ok.proto
```
### Generated code is correct
```ruby
# data_twirp.rb
# ...SKIP...
rpc :create, SetDataRequest, Ok::Response, :ruby_method => :create
# ...SKIP...
```
Contributor guide
Research direction
Reproduce the issue with data.proto and ok.proto using the two protoc command variants, then compare data_twirp.rb with the separately generated output. Trace the generator behavior that determines the RPC response type; done means the combined invocation emits Ok::Response just like the separate invocations.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- backend-api-design
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100