reqwest-middleware icon indicating copy to clipboard operation
reqwest-middleware copied to clipboard

Compilation issue with mininal dependencies version

Open ilaborie opened this issue 3 months ago • 1 comments

Bug description

I have a compilation issue with these lines:

use reqwest::header::{HeaderMap, HeaderValue, ACCEPT};
use reqwest::{Client, Response, StatusCode, Url};
use reqwest_middleware::ClientWithMiddleware;
use reqwest_tracing::TracingMiddleware;

// ...

let mut headers = HeaderMap::new();
headers.insert(
   ACCEPT,
   HeaderValue::from_static("application/vnd.schemaregistry.v1+json"),
);
let reqwest_client = Client::builder().default_headers(headers).build()?;
let client = reqwest_middleware::ClientBuilder::new(reqwest_client)
    // Insert the tracing middleware
    .with(TracingMiddleware::default())
    .build();
error[E0277]: the trait bound `TracingMiddleware<DefaultSpanBackend>: reqwest_middleware::Middleware` is not satisfied
  --> schema-registry-api/src/service/mod.rs:52:19
   |
52 |             .with(TracingMiddleware::default())
   |              ---- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `for<'a> Fn(reqwest::Request, &'a mut http::extensions::Extensions, Next<'a>)` is not implemented for `TracingMiddleware<DefaultSpanBackend>`, which is required by `TracingMiddleware<DefaultSpanBackend>: reqwest_middleware::Middleware`
   |              |
   |              required by a bound introduced by this call
   |
   = note: required for `TracingMiddleware<DefaultSpanBackend>` to implement `reqwest_middleware::Middleware`
note: required by a bound in `reqwest_middleware::ClientBuilder::with`
  --> /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/reqwest-middleware-0.4.0/src/client.rs:51:12
   |
49 |     pub fn with<M>(self, middleware: M) -> Self
   |            ---- required by a bound in this associated function
50 |     where
51 |         M: Middleware,
   |            ^^^^^^^^^^ required by this bound in `ClientBuilder::with`

For more information about this error, try `rustc --explain E0277`.

With these dependencies

[dependencies]
reqwest = { version = "0.12.9", features = ["json"], default-features = false }
reqwest-middleware = { version = "0.4.0", features = ["json"] }
reqwest-tracing = "0.5.4"

AND when I try to compile with the minimal dependencies versions using cargo +nightly update -Zminimal-versions to update the Cargo.lock file with the minimal versions

See https://github.com/ilaborie/schema-registry-cli/actions/runs/12104246014/job/33747408600

To Reproduce

Should be reproduced with the same dependencies version AND with the cargo +nightly update -Zminimal-versions to set minimal version in the Cargo.lock file.

Expected behavior

Should compile

Environment

  • OS: Gitub Actions ubuntu-latest
  • Rust version stable, today the 1.83.0

Additional context

ilaborie avatar Dec 01 '24 10:12 ilaborie