-
Notifications
You must be signed in to change notification settings - Fork 26
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
(KeyError) key :elixir_module_prefix not found in: %Google.Protobuf.FileOptions{} #125
Comments
Hey I was able to recreate this issue. syntax = "proto3";
option java_multiple_files = true;
option java_package = "example.apps.services.grpc";
option java_outer_classname = "ProtocolProto";
service ProtocolService {
rpc Recover(RecoveryRequest) returns (ProtocolReply) {}
}
message RecoveryRequest {
int64 timestamp = 1;
}
message ProtocolReply {
string message = 1;
} If we try to compile it with:
It will complain about the error stated on the issue If we comment the options out it will compile without any problem |
Hey I found a possible solution for this problem. ctx = %{
ctx
| package: desc.package || "",
syntax: syntax(desc.syntax),
module_prefix: (desc.options && desc.options.elixir_module_prefix) || (desc.package || "")
} The problem here is because the protofile can have custom options, if elixir_module_prefix if not present will crash the tool. an easy fix will be something like. module_prefix: (desc.options && Map.get(desc.options, :elixir_module_prefix)) || (desc.package || "") I still don't get why it started to fail 🍡 |
It most likely started to fail because of a backwards incompatible change made to the elixir proto library. Nothing changed in the twirp library. We can defend against it in this code as @saulbensach demonstrated or by fixing the elixir proto library. Its probably easier to just defend against it here. if someone would like to submit a PR for that, that would be great. |
(KeyError) key :elixir_module_prefix not found in: %Google.Protobuf.FileOptions{}
https://github.com/keathley/twirp-elixir/blob/master/lib/twirp/protoc/generator.ex#L25 it appears
protobuf-elixir/protobuf
no longer has that key though it looks like it might exist as some sort of monkey-patched protobuf extension if you require the right module.I'm sorry this isn't a patch, I'm new to Elixir and unsure if we should be testing for the key or requiring in the extension.
The text was updated successfully, but these errors were encountered: