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

Mislabeled exception when unable to resolve dependency graph #133

Open
m1guelpf opened this issue Dec 25, 2023 · 1 comment
Open

Mislabeled exception when unable to resolve dependency graph #133

m1guelpf opened this issue Dec 25, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@m1guelpf
Copy link
Contributor

I was very confused when I got this error pointing to the default route that comes with the template.

ERROR: 
  x I don't know how to handle the type returned by `app::routes::system::health_check`.
  |
  |     ,-[app/src/routes/mod.rs:10:1]
  |  10 | pub fn handler(bp: &mut Blueprint) {
  |  11 |     bp.route(GET, "/healthz", f!(crate::routes::system::health_check));
  |     :                               ^^^^^^^^^^^^^^^^^^^|^^^^^^^^^^^^^^^^^^^
  |     :                                                  `-- The request handler was registered here
  |  12 | }
  |     `----
  |    ,-[app/src/routes/system.rs:4:1]
  |  4 | #[must_use]
  |  5 | pub const fn health_check() -> StatusCode {
  |    :                                ^^^^^|^^^^
  |    :                                     `-- The output type that I can't handle
  |  6 |     StatusCode::OK
  |    `----

Turns out, the error triggers when you try to import a crate which uses a different version of a dependency your app crate also requires. I've created an example repo with two commits. The first one does not compile with the above error, while mirroring the features on the app crate compiles without issues.

@LukeMathWalker
Copy link
Owner

LukeMathWalker commented Dec 25, 2023

Setting PAVEX_DEBUG=1 before executing cargo px check surfaces the deeper error message:

There are multiple packages named `http` among the dependencies of app 0.0.0 (path+file:///Users/luca/code/scratch/
pavex_statuscode_repro/app). In order to disambiguate among them, I need to know their versions.
Unfortunately, I couldn't extract the expected version for `http` from HTML root URL included in the JSON documentation for
`app 0.0.0 (path+file:///Users/luca/code/scratch/pavex_statuscode_repro/app)`.
This due to a limitation in `rustdoc` itself: follow https://github.com/rust-lang/compiler-team/issues/622 to track
progress on this issue.

To fix this properly, I'd need to see some progress on rust-lang/compiler-team#635, but we can definitely return a better error message.

LukeMathWalker added a commit that referenced this issue Feb 9, 2024
…t identify an external rustdoc JSON crate.

It significantly mitigates #133.
LukeMathWalker added a commit that referenced this issue Feb 9, 2024
…t identify an external rustdoc JSON crate. (#188)

It significantly mitigates #133.
@LukeMathWalker LukeMathWalker added the bug Something isn't working label Feb 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants