Giter Site home page Giter Site logo

Comments (3)

keathley avatar keathley commented on August 17, 2024 1

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.

from twirp-elixir.

saulbensach avatar saulbensach commented on August 17, 2024

Hey I was able to recreate this issue.
The problem is the extra options that you can declare on the proto file. In my example, we are using the proto for Java and Elixir we have something like this.

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:

protoc --proto_path=./example example/grpc/example.proto --twirp_elixir_out=./elixir-proto-lib/example --elixir_out=./elixir-proto-lib/example

It will complain about the error stated on the issue
key :elixir_module_prefix not found in: %Google.Protobuf.FileOptions{

If we comment the options out it will compile without any problem
This was not a problem for us for like 1 year or something like that, but this past month something changed and now it does no longer work.

from twirp-elixir.

saulbensach avatar saulbensach commented on August 17, 2024

Hey I found a possible solution for this problem.
the module Twirp.Protoc.Generator contains the fun generate_content. Here we can that the ctx is being build.

    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 🍡

from twirp-elixir.

Related Issues (7)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.