Fix IntoResponse for tuples overriding error response codes (#3603)

Co-authored-by: David Pedersen <[email protected]>
Co-authored-by: Yann Simon <[email protected]>
This commit is contained in:
Jonas Platte
2026-01-18 20:20:18 +01:00
committed by GitHub
co-authored by David Pedersen Yann Simon
parent 81e727faf6
commit 576968b406
10 changed files with 479 additions and 38 deletions
+7 -2
View File
@@ -4,7 +4,7 @@ use axum_core::__composite_rejection as composite_rejection;
use axum_core::__define_rejection as define_rejection;
use axum_core::{
extract::{rejection::BytesRejection, FromRequest, Request},
response::{IntoResponse, Response},
response::{IntoResponse, IntoResponseFailed, Response},
RequestExt,
};
use bytes::BytesMut;
@@ -131,7 +131,12 @@ where
let mut buf = BytesMut::with_capacity(self.0.encoded_len());
match &self.0.encode(&mut buf) {
Ok(()) => buf.into_response(),
Err(err) => (StatusCode::INTERNAL_SERVER_ERROR, err.to_string()).into_response(),
Err(err) => (
StatusCode::INTERNAL_SERVER_ERROR,
IntoResponseFailed,
err.to_string(),
)
.into_response(),
}
}
}
+7 -2
View File
@@ -1,6 +1,6 @@
use std::sync::Arc;
use axum_core::response::{IntoResponse, Response};
use axum_core::response::{IntoResponse, IntoResponseFailed, Response};
use bytes::{BufMut, Bytes, BytesMut};
use http::{header, HeaderValue, StatusCode};
use serde_core::Serialize;
@@ -78,7 +78,12 @@ impl IntoResponse for ErasedJson {
bytes,
)
.into_response(),
Err(err) => (StatusCode::INTERNAL_SERVER_ERROR, err.to_string()).into_response(),
Err(err) => (
StatusCode::INTERNAL_SERVER_ERROR,
IntoResponseFailed,
err.to_string(),
)
.into_response(),
}
}
}