oxidecomputer / progenitor

An OpenAPI client generator
426 stars 55 forks source link

`cargo-progenitor` relies on `build.rs` output present only in development #828

Closed BatmanAoD closed 3 weeks ago

BatmanAoD commented 1 month ago

I am trying to determine if progenitor is a good fit to replace my company's current usage of the Rust OpenAPI Generator, and I ran into some difficulties just smoke-testing the tool.

In particular, I would assume that all the APIs in the sample_api folder are compatible with progenitor, because I don't see anything to the contrary in the primary readme or the sample folder's readme. However, the CLI progenitor command (run from the main branch of the repo) panicked when trying to build a client for the api.github.com.json file:

❯ cargo run --bin cargo-progenitor -- progenitor -i ~/Downloads/api.github.com.json -o ~/tmp/gitapiclient -n testclient -v 0.1.0
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.13s
     Running `target/debug/cargo-progenitor progenitor -i /Users/kstrand/Downloads/api.github.com.json -o /Users/kstrand/tmp/gitapiclient -n testclient -v 0.1.0`
thread 'main' panicked at progenitor-impl/src/method.rs:2119:27:
not yet implemented: more media types than expected for markdown/render-raw: 2
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Is this a known issue?


Using version 0.7.0 (the version installed by cargo install cargo-progenitor), propolis-server.json and nexus.json failed as well; I am assuming these are known issues that have been fixed in main, but please let me know if not.

ahl commented 4 weeks ago

See also #395

ahl commented 4 weeks ago

I wasn't able to reproduce failures on propolis-server.json and nexus.json on 0.7.0. Can you describe the failures you've seen with those?

BatmanAoD commented 4 weeks ago

Sure; I'll include the last few lines of non-error output, then the error, with RUST_BACKTRACE=1.

Here's nexus.json:

 267  std::num::NonZeroU32
 268  option 268
 269  option 198
-----------------------------------------------------

thread 'main' panicked at /Users/kstrand/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cargo-progenitor-0.7.0/src/main.rs:280:48:
called `Option::unwrap()` on a `None` value
stack backtrace:
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic
   3: core::option::unwrap_failed
   4: cargo_progenitor::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

And propolis-server.json:

  41  box 24
  42  ()
-----------------------------------------------------

thread 'main' panicked at /Users/kstrand/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cargo-progenitor-0.7.0/src/main.rs:290:45:
called `Option::unwrap()` on a `None` value
stack backtrace:
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic
   3: core::option::unwrap_failed
   4: cargo_progenitor::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

I'm on an Apple M1, in case Apple Silicon might be making a difference here.

ahl commented 3 weeks ago

Interesting. So that's failing here:

https://github.com/oxidecomputer/progenitor/blob/main/cargo-progenitor/src/main.rs#L278-L281

We must be missing the dependency information... because of course we are: cargo-progenitor doesn't depend on futures or a bunch of these other crates. I'm not quite sure how this works at all, but certainly it doesn't work on the compiled binary version. We'll get this sorted out--thanks for raising this issue!

ahl commented 3 weeks ago

I'm going to repurpose this bug to focus on the intrinsic brokenness of cargo-progenitor and leave #395 to address the GitHub client generation issues.

BatmanAoD commented 3 weeks ago

Was this closed inadvertently?

ahl commented 3 weeks ago

it was; thanks