pavex
pavex copied to clipboard
Mislabeled exception when unable to resolve dependency graph
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.
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 https://github.com/rust-lang/compiler-team/issues/635, but we can definitely return a better error message.