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

Compilation issue with mininal dependencies version #204

Open
ilaborie opened this issue Dec 1, 2024 · 1 comment
Open

Compilation issue with mininal dependencies version #204

ilaborie opened this issue Dec 1, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@ilaborie
Copy link

ilaborie commented Dec 1, 2024

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

@matt-phylum
Copy link

The minimal version of reqwest-middleware compatible with reqwest-tracing is 0.3.1, but because of the way reqwest-middleware works, all middlewares and the code composing the middlewares to build the client must use the same version of reqwest-middleware.

A similar problem occurs if you try to use reqwest-tracing with reqwest-middleware 0.3 without -Zminimal-versions because cargo update will select reqwest-middleware 0.4 for reqwest-tracing. This case is occurring with stable Rust, not nightly rust like -Zminimal-versions.

The >0.3.0, < 0.5.0 version requirement was supposed to avoid disruptions to consumers (#198), but now it is creating disruptions to consumers because cargo update doesn't understand that the it needs to select a version of reqwest-middleware compatible with both reqwest-tracing and the crate using reqwest-tracing. I wonder if reqwest-tracing could have an optional dependency on reqwest-middleware 0.3 so the same version can work for either or both when enabled, although that would be a breaking change and wouldn't immediately solve things for me because I'm actually seeing this problem with reqwest-tracing being a dependency of a dependency, and requiring a new feature to be enabled for 0.3 compatibility would be a breaking change, so I would need the dependency to update to the new version first.

appcypher added a commit to appcypher/monocore that referenced this issue Dec 10, 2024
- Downgraded `reqwest-middleware` from 0.4 to 0.3 due to [compatibility issues](TrueLayer/reqwest-middleware#204).
- Downgraded `reqwest-retry` from 0.7 to 0.6 for similar reasons.
- Updated `Cargo.lock` to reflect these changes and ensure consistent dependency resolution.
- Removed unnecessary version specifications in `Cargo.lock` for `reqwest-middleware`.

These changes maintain compatibility with existing code while addressing dependency constraints.
appcypher added a commit to appcypher/monocore that referenced this issue Dec 10, 2024
…#69)

* refactor(config): simplify service model and improve volume handling

- Consolidate service types into a single Service struct
- Add direct volume and environment variable support to Service
- Improve volume path normalization and validation
- Add new helper methods for resolving volumes and environment variables
- Update tests to reflect new configuration model
- Add pretty-error-debug dependency
- Update various dependency versions in Cargo.toml

BREAKING CHANGE: Removes service type variants (Default, HttpHandler, Precursor) in favor of a single unified Service struct. This change simplifies the configuration model while maintaining all functionality.

* chore(deps): downgrade reqwest-middleware and reqwest-retry versions

- Downgraded `reqwest-middleware` from 0.4 to 0.3 due to [compatibility issues](TrueLayer/reqwest-middleware#204).
- Downgraded `reqwest-retry` from 0.7 to 0.6 for similar reasons.
- Updated `Cargo.lock` to reflect these changes and ensure consistent dependency resolution.
- Removed unnecessary version specifications in `Cargo.lock` for `reqwest-middleware`.

These changes maintain compatibility with existing code while addressing dependency constraints.

* chore(test): Skip fstab test in CI as it breaks for reason I don't yet know
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

2 participants