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

Panic in prost-build with potentially unsupported extern_path #932

Open
kriswuollett opened this issue Oct 16, 2023 · 0 comments
Open

Panic in prost-build with potentially unsupported extern_path #932

kriswuollett opened this issue Oct 16, 2023 · 0 comments

Comments

@kriswuollett
Copy link

kriswuollett commented Oct 16, 2023

Similar to #838, I'm encountering the following panic when attempting to add an external_path to the builder:

prost/prost-build/src/lib.rs

Lines 1216 to 1221 in 97cd4e2

if let Some(ref mut service_generator) = self.service_generator {
for (module, package) in packages {
let buf = modules.get_mut(&module).unwrap();
service_generator.finalize_package(&package, buf);
}
}

The form of the externs I'm newly attempting to use are like: .my.package -> ::my_package::pb. I don't know if using a submodule is supported or not, but that would be a separate issue. The issue here is that the panic has no information to the end-user of what pre-condition failed. So it is extremely difficult to know if what I'm doing is supported or not.

thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', /Users/kris/.cargo/registry/src/index.crates.io-6f17d22bba15001f/prost-build-0.12.1/src/lib.rs:1218:52
  stack backtrace:
     0: rust_begin_unwind
               at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/std/src/panicking.rs:593:5
     1: core::panicking::panic_fmt
               at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/core/src/panicking.rs:67:14
     2: core::panicking::panic
               at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/core/src/panicking.rs:117:5
     3: core::option::Option<T>::unwrap
               at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/core/src/option.rs:935:21
     4: prost_build::Config::generate
               at /Users/kris/.cargo/registry/src/index.crates.io-6f17d22bba15001f/prost-build-0.12.1/src/lib.rs:1218:27
     5: prost_build::Config::compile_fds
               at /Users/kris/.cargo/registry/src/index.crates.io-6f17d22bba15001f/prost-build-0.12.1/src/lib.rs:969:23
     6: prost_build::Config::compile_protos
               at /Users/kris/.cargo/registry/src/index.crates.io-6f17d22bba15001f/prost-build-0.12.1/src/lib.rs:1116:9
     7: tonic_build::prost::Builder::compile_with_config
               at /Users/kris/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tonic-build-0.10.2/src/prost.rs:607:9
     8: tonic_build::prost::Builder::compile
               at /Users/kris/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tonic-build-0.10.2/src/prost.rs:533:9
     9: REDACTED
               at REDACTED
    10: REDACTED
               at REDACTED
    11: build_script_build::main
               at ./build.rs:19:5
    12: core::ops::function::FnOnce::call_once
               at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/core/src/ops/function.rs:250:5
  note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Externs are working for me when I used code like the following (not a submodule nor complete package mapping):

    for t in vec!["Any", "Duration"] {
        builder = builder.extern_path(
            format!(".google.protobuf.{t}"),
            format!("::prost_types::{t}"),
        );
    }
@kriswuollett kriswuollett changed the title Panic in prost-build with erroneous Panic in prost-build with potentially unsupported extern_path Oct 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant