Skip to content

Custom options are not parsed correctly #138

@alirezasharifianzadeh

Description

@alirezasharifianzadeh

Hi, I am trying to parse this proto file:

syntax = "proto3";

import "google/protobuf/descriptor.proto";

extend google.protobuf.EnumValueOptions {
  optional uint32 my_enum_value_option = 50005;
}

enum MyEnum {
  UNKNOWN = 0;
  FOO = 1 [(my_enum_value_option) = 321];
  BAR = 2;
}

with this command:

protoc -I . --elixir_out=gen_descriptors=true:. --plugin=/Users/alirezasharifianzadeh/.asdf/installs/elixir/1.11.1/.mix/escripts/protoc-gen-elixir *.proto

But the output does not contain my_enum_value_option value!

Here is the elixir output:

defmodule MyEnum do
  @moduledoc false
  use Protobuf, enum: true, syntax: :proto2
  @type t :: integer | :UNKNOWN | :FOO | :BAR

  def descriptor do
    # credo:disable-for-next-line
    Elixir.Google.Protobuf.EnumDescriptorProto.decode(
      <<10, 6, 77, 121, 69, 110, 117, 109, 18, 11, 10, 7, 85, 78, 75, 78, 79, 87, 78, 16, 0, 18,
        11, 10, 3, 70, 79, 79, 16, 1, 26, 2, 8, 0, 18, 7, 10, 3, 66, 65, 82, 16, 2>>
    )
  end

  field :UNKNOWN, 0

  field :FOO, 1

  field :BAR, 2
end
%Google.Protobuf.EnumDescriptorProto{
  name: "MyEnum",
  options: nil,
  reserved_name: [],
  reserved_range: [],
  value: [
    %Google.Protobuf.EnumValueDescriptorProto{
      name: "UNKNOWN",
      number: 0,
      options: nil
    },
    %Google.Protobuf.EnumValueDescriptorProto{
      name: "FOO",
      number: 1,
      options: %Google.Protobuf.EnumValueOptions{
        deprecated: false,
        uninterpreted_option: []
      }
    },
    %Google.Protobuf.EnumValueDescriptorProto{
      name: "BAR",
      number: 2,
      options: nil
    }
  ]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Effort:LargeKind:BugA bug. Can be a documentation bug, Dialyzer issue, or anything that just "doesn't work".

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions