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

Version 2.0.0b4 fail to generate plugins concurrently #312

Open
TamirFriedman-RecoLabs opened this issue Jan 5, 2022 · 5 comments
Open
Labels
compiler-bug The compiler is broken

Comments

@TamirFriedman-RecoLabs
Copy link

Usage fails with BetterProto 2.0.0b4 Version

$ buf generate -vvv proto
E0105 15:39:19.511094 1771702 template.go:991] created a body with 0 properties in the message, this might be unintended: name:"ModifyTileDisplayStateRequest"  field:{name:"tile_name"  number:1  label:LABEL_OPTIONAL  type:TYPE_STRING  json_name:"tileName"}  field:{name:"tile_state"  number:2  label:LABEL_OPTIONAL  type:TYPE_ENUM  type_name:".reco.services.v1.TileDisplayState"  json_name:"tileState"}
Traceback (most recent call last):
  File "/usr/local/bin/protoc-gen-python_betterproto", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.9/dist-packages/betterproto/plugin/main.py", line 32, in main
    response = generate_code(request)
  File "/usr/local/lib/python3.9/dist-packages/betterproto/plugin/parser.py", line 107, in generate_code
    read_protobuf_service(service, index, output_package)
  File "/usr/local/lib/python3.9/dist-packages/betterproto/plugin/parser.py", line 191, in read_protobuf_service
    ServiceMethodCompiler(
  File "<string>", line 7, in __init__
  File "/usr/local/lib/python3.9/dist-packages/betterproto/plugin/models.py", line 683, in __post_init__
    self.mutable_default_args  # ensure this is called before rendering
  File "/usr/local/lib/python3.9/dist-packages/betterproto/plugin/models.py", line 720, in mutable_default_args
    and f.default_value_string != "None"
  File "/usr/local/lib/python3.9/dist-packages/betterproto/plugin/models.py", line 486, in default_value_string
    enum = next(
StopIteration
Failure: failed to generate plugins concurrently: failed to execute plugins concurrently: failed to generate: exit status 1.

Replacing to older version

$ pip install betterproto[compiler]==2.0.0b3
Collecting betterproto[compiler]==2.0.0b3
  Downloading betterproto-2.0.0b3-py3-none-any.whl (59 kB)
     |████████████████████████████████| 59 kB 611 kB/s 
Installing collected packages: betterproto
  Attempting uninstall: betterproto
    Found existing installation: betterproto 2.0.0b4
    Uninstalling betterproto-2.0.0b4:
      Successfully uninstalled betterproto-2.0.0b4
Successfully installed betterproto-2.0.0b3

Usage succeed with BetterProto 2.0.0b3 Version

$ buf generate -vvv proto
E0105 15:54:45.424446 1781827 template.go:991] created a body with 0 properties in the message, this might be unintended: 
Writing __init__.py
Writing google/__init__.py
Writing google/api/__init__.py
Writing google/longrunning/__init__.py
Writing google/rpc/__init__.py
Writing grpc/__init__.py
Writing grpc/gateway/__init__.py
Writing grpc/gateway/protoc_gen_openapiv2/__init__.py
Writing grpc/gateway/protoc_gen_openapiv2/options/__init__.py
Writing validate/__init__.py
@Gobot1234
Copy link
Collaborator

Hi, sorry about this could you perhaps attach the file that causes this error?

@Gobot1234 Gobot1234 added the bug Something isn't working label Jan 5, 2022
@efokschaner
Copy link
Contributor

Given that I removed mutable_default_args this might work after #311

@TamirFriedman-RecoLabs if you want to try the efokschaner:methods-take-messages branch to find out it would help.

@roblabla
Copy link
Contributor

roblabla commented Jan 19, 2022

The error is caused by embedded enums. I have a similar error, here's a minimal reproducer:

syntax = "proto3";

package test;

message Msg {
    enum InnerEnum {
        ENUM_ZERO = 0;
        ENUM_ONE = 1;
    }
    InnerEnum en = 1;
}

message MsgReply {}

service Service {
    rpc Method(Msg) returns (MsgReply);
}

Moving InnerEnum outside msg stops the error from occuring. I suspect the issue is due to the new support for open enums.

@roblabla
Copy link
Contributor

This appears to be fixed by d260f07 somehow

@Gobot1234
Copy link
Collaborator

The error is caused by embedded enums. I have a similar error, here's a minimal reproducer:

syntax = "proto3";



package test;



message Msg {

    enum InnerEnum {

        ENUM_ZERO = 0;

        ENUM_ONE = 1;

    }

    InnerEnum en = 1;

}



message MsgReply {}



service Service {

    rpc Method(Msg) returns (MsgReply);

}

Moving InnerEnum outside msg stops the error from occuring. I suspect the issue is due to the new support for open enums.

I'll add a few tests so that issues like this don't happen again

@Gobot1234 Gobot1234 added compiler-bug The compiler is broken and removed bug Something isn't working labels Feb 15, 2022
Gobot1234 added a commit to Gobot1234/python-betterproto that referenced this issue Feb 15, 2022
Gobot1234 added a commit that referenced this issue Apr 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler-bug The compiler is broken
Projects
None yet
Development

No branches or pull requests

4 participants