Skip to content
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

protoc-gen-elixir will crash when indent with 4 space #280

Open
wingyplus opened this issue Jun 3, 2022 · 2 comments
Open

protoc-gen-elixir will crash when indent with 4 space #280

wingyplus opened this issue Jun 3, 2022 · 2 comments
Labels
Kind:Bug A bug. Can be a documentation bug, Dialyzer issue, or anything that just "doesn't work". Platform:Windows Windows-related issues.

Comments

@wingyplus
Copy link
Contributor

wingyplus commented Jun 3, 2022

From https://github.com/wingyplus/grpc/blob/main/test/support/helloworld.proto. If I change message field by diff below:

diff --git a/test/support/helloworld.proto b/test/support/helloworld.proto
index 0436df6..9bf602a 100644
--- a/test/support/helloworld.proto
+++ b/test/support/helloworld.proto
@@ -11,7 +11,7 @@ service Greeter {

 // The request message containing the user's name.
 message HelloRequest {
-  string name = 1;
+    string name = 1;
 }

 // The response message containing the greetings

The protoc-gen-elixir will crash with output:

** (MatchError) no match of right hand side value: "st"
    (protobuf 0.10.0) lib/protobuf/decoder.ex:70: Protobuf.Decoder.handle_field/5
    (protobuf 0.10.0) lib/protobuf/decoder.ex:17: Protobuf.Decoder.decode/2
    (protobuf 0.10.0) lib/protobuf/decoder.ex:231: Protobuf.Decoder.value_for_field/3
    (protobuf 0.10.0) lib/protobuf/decoder.ex:382: Protobuf.Decoder.update_in_message/3
    (protobuf 0.10.0) lib/protobuf/decoder.ex:176: Protobuf.Decoder.handle_value/6
    (protobuf 0.10.0) lib/protobuf/decoder.ex:17: Protobuf.Decoder.decode/2
    (protobuf 0.10.0) lib/protobuf/decoder.ex:231: Protobuf.Decoder.value_for_field/3
    (protobuf 0.10.0) lib/protobuf/decoder.ex:382: Protobuf.Decoder.update_in_message/3
--elixir_out: protoc-gen-elixir: Plugin failed with status code 1.

I run it on Windows 11 with PowerShell Core.

@whatyouhide whatyouhide added Kind:Bug A bug. Can be a documentation bug, Dialyzer issue, or anything that just "doesn't work". Platform:Windows Windows-related issues. labels Jun 20, 2022
@juliannoble
Copy link

This occurs also in Windows 10 with standard command prompt or pwsh
For me it's not strictly based on the indenting.
e.g I get the error with 2 indent spaces below, but apparently not 3 or more
message HelloRequest {
string name= 1;
}
however, with
message HelloReply {
string name123456789 = 1;
}
I get the error seemingly with any number of indents including zero.
(but name1 name12 etc are all fine, as are longer strings such as name1234567891234..)

error is:

protoc --elixir_out=./lib protos/greeter2.proto
** (Protobuf.DecodeError) cannot decode binary data, unknown wire type: 7
(protobuf 0.11.0) lib/protobuf/decoder.ex:80: Protobuf.Decoder.handle_field/5
(protobuf 0.11.0) lib/protobuf/decoder.ex:17: Protobuf.Decoder.decode/2
(protobuf 0.11.0) lib/protobuf/decoder.ex:231: Protobuf.Decoder.value_for_field/3
(protobuf 0.11.0) lib/protobuf/decoder.ex:382: Protobuf.Decoder.update_in_message/3
(protobuf 0.11.0) lib/protobuf/decoder.ex:176: Protobuf.Decoder.handle_value/6
(protobuf 0.11.0) lib/protobuf/decoder.ex:17: Protobuf.Decoder.decode/2
(protobuf 0.11.0) lib/protobuf/decoder.ex:231: Protobuf.Decoder.value_for_field/3
(protobuf 0.11.0) lib/protobuf/decoder.ex:382: Protobuf.Decoder.update_in_message/3
--elixir_out: protoc-gen-elixir: Plugin failed with status code 1.

I thought I could work around it by adjusting names or spaces here and there - but in any non-trivial file it becomes too hard to debug because multiple lines can be causing the error so it's a real showstopper.

@juliannoble
Copy link

As a workaround for now I'm trying :protox which seems able to compile proto3 files on windows - but there is less info out there on using this library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Kind:Bug A bug. Can be a documentation bug, Dialyzer issue, or anything that just "doesn't work". Platform:Windows Windows-related issues.
Projects
None yet
Development

No branches or pull requests

3 participants