Skip to content

http-body version incompatible #1243

@lijingrs

Description

@lijingrs

Describe the bug

error[E0277]: the trait bound axum::body::Bytes: HttpBody is not satisfied because the trait comes from a different crate version

this error comes when I create web app service with axum 0.8

Image Image Image

Regression Issue

  • Select this option if this issue appears to be a regression.

Expected Behavior

update the htpp-body version

Current Behavior

http-body version too many

Reproduction Steps

it comes with compile time when add aws-sdk-s3 aws-config

aws-config = { version = "1.5.14", features = ["behavior-version-latest"] }
aws-sdk-s3 = { version = "1.69.0"}
axum = { version = "0.8.1" ,features = ["multipart","macros"]}

let client = aws_sdk_s3::Client::new(
&SdkConfig::builder()
.region(Region::new(s3_config.region.clone()))
.endpoint_url(s3_config.endpoint_url.clone())
.behavior_version(BehaviorVersion::latest())
.credentials_provider(SharedCredentialsProvider::new(Credentials::new(
s3_config.access_key_id.clone(),
s3_config.secret_access_key.clone(),
None,
None,
PROVIDER_NAME
)))
.build(),
);

pub async fn upload(&self, data:Bytes, bucket:&str, key:&str) -> CommonResult{
let output = selfclient
.put_object()
.bucket(bucket)
.key(key)
.body(ByteStream::from(data))
.send()
.await?;
let etag = output.e_tag.unwrap_or_else(|| "".to_string());
info!("ETag: {}", etag);
Ok(etag)
}

Possible Solution

No response

Additional Information/Context

No response

Version

aws-config = { version = "1.5.14", features = ["behavior-version-latest"] }
aws-sdk-s3 = { version = "1.69.0"}

Environment details (OS name and version, etc.)

macos

Logs

error[E0277]: the trait bound axum::body::Bytes: HttpBody is not satisfied because the trait comes from a different crate version
--> src/application/system/service/file_service.rs:75:56
|
75 | Path((,id)): Path<(i64,i64)> )-> impl IntoResponse{
| ________________________________________________________^
76 | | let file = FileDomainService::find_by_id(id).await.unwrap();
77 | | if file.is_none(){
78 | | return Err(StatusCode::NOT_FOUND);
... |
89 | | Ok(response)
90 | | }
| |
^ the trait HttpBody is not implemented for axum::body::Bytes
|
note: there are multiple different versions of crate http_body in the dependency graph
--> /Users/lijing/.cargo/registry/src/rsproxy.cn-8f6827c7555bfaf8/http-body-1.0.1/src/lib.rs:38:1
|
38 | pub trait Body {
| ^^^^^^^^^^^^^^ this is the required trait
|
::: src/presentation/router/auth_routes.rs:1:5
|
1 | use axum::Router;
| ---- one version of crate http_body is used here, as a dependency of crate axum_core
|
::: src/infrastructure/utils/aws_s3_util.rs:1:5
|
1 | use aws_config::SdkConfig;
| ---------- one version of crate http_body is used here, as a dependency of crate aws_smithy_types
|
::: /Users/lijing/.cargo/registry/src/rsproxy.cn-8f6827c7555bfaf8/bytes-1.9.0/src/bytes.rs:102:1
|
102 | pub struct Bytes {
| ---------------- this type doesn't implement the required trait
|
::: /Users/lijing/.cargo/registry/src/rsproxy.cn-8f6827c7555bfaf8/http-body-0.4.6/src/collect.rs:14:1
|
14 | / pin_project! {
15 | | /// Future that resolves into a [Collected].
16 | | pub struct Collect
17 | | where
... |
24 | | }
25 | | }
| |_- this is the found trait
= help: you can use cargo tree to explore your dependency tree

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions