dropbox / pb-jelly

A protobuf code generation framework for the Rust language developed at Dropbox.
Apache License 2.0
610 stars 25 forks source link

codegen.py assumes proto files in a subdirectory #78

Closed JParisFerrer closed 3 years ago

JParisFerrer commented 3 years ago

protos/myproto.proto fails with a confusing error message (see below), but moving it into protos/myproto/myproto.proto will codegen successfully. The comment here right above the error sort of suggests its not expected.

[/home/jordi/.cargo/registry/src/github.com-1ecc6299db9ec823/pb-jelly-gen-0.0.4/src/lib.rs:169] output.status.code() = Some(
    1,
)
stdout=
stderr=Traceback (most recent call last):
  File "/tmp/codegenMIlOse/codegen.py", line 1783, in <module>
    generate_code(request, response)
  File "/tmp/codegenMIlOse/codegen.py", line 1768, in generate_code
    generate_single_crate(ctx, "", to_generate, response)
  File "/tmp/codegenMIlOse/codegen.py", line 1683, in generate_single_crate
    mod_name = mod_parts[-1]
IndexError: list index out of range
--rust_out: protoc-gen-rust: Plugin failed with status code 1.

From discussion over in #77:

one option provide a better error message - telling folks to move the proto file into a directory support this case - perhaps picking a crate name to match the file name? I haven't really thought it through to decide which case to prefer. Feel free to fix it! It seems like it would be hard to add a unit test in our testing framework for error situations (first option) - > but we could certainly test the second option.