Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 3 additions & 74 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ tokio-stream = { version = "0.1.15", features = ["sync"] }
tracing = "0.1.41"
tracing-subscriber = { version = "0.3.19", features = ["json"] }
url = "2.5.0"
warp = { git = 'https://github.com/cowprotocol/warp.git', rev = "586244e", default-features = false }
app-data = { path = "crates/app-data" }
arc-swap = "1.7.1"
async-stream = "0.3.5"
Expand Down
10 changes: 7 additions & 3 deletions crates/driver/src/infra/api/routes/healthz.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
use axum::{http::StatusCode, response::IntoResponse, routing::get};
use axum::{
http::StatusCode,
response::{IntoResponse, Response},
routing::get,
};

pub(in crate::infra::api) fn healthz(app: axum::Router<()>) -> axum::Router<()> {
app.route("/healthz", get(route))
}

async fn route() -> impl IntoResponse {
StatusCode::OK
async fn route() -> Response {
StatusCode::OK.into_response()
}
4 changes: 2 additions & 2 deletions crates/driver/src/tests/setup/orderbook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use {
Router,
extract::Path,
http::StatusCode,
response::IntoResponse,
response::{IntoResponse, Response},
routing::get,
},
std::{collections::HashMap, net::SocketAddr},
Expand Down Expand Up @@ -59,7 +59,7 @@ impl Orderbook {
async fn app_data_handler(
Path(app_data): Path<String>,
Extension(app_data_storage): Extension<HashMap<app_data::AppDataHash, app_data::Root>>,
) -> impl IntoResponse {
) -> Response {
tracing::debug!("Orderbook received an app_data request: {}", app_data);

let app_data_hash = match app_data.parse::<app_data::AppDataHash>() {
Expand Down
9 changes: 7 additions & 2 deletions crates/e2e/src/setup/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@
//! cluster.

use {
axum::{Router, body::Body, http::Request, response::IntoResponse},
axum::{
Router,
body::Body,
http::Request,
response::{IntoResponse, Response},
},
hyper::body::to_bytes,
std::{collections::VecDeque, net::SocketAddr, sync::Arc},
tokio::{sync::RwLock, task::JoinHandle},
Expand Down Expand Up @@ -109,7 +114,7 @@ async fn handle_request(
client: reqwest::Client,
state: ProxyState,
req: Request<Body>,
) -> impl IntoResponse {
) -> Response {
let (parts, body) = req.into_parts();

// Convert body to bytes once for reuse across retries
Expand Down
54 changes: 30 additions & 24 deletions crates/e2e/tests/e2e/malformed_requests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ async fn http_validation(web3: Web3) {

assert_eq!(
response.status(),
StatusCode::NOT_FOUND,
"Expected 404 for invalid OrderUid ({description}): {uid}"
StatusCode::BAD_REQUEST,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strictly speaking axum using correct HTTP error codes makes this migration backwards incompatible. I'm not saying we should keep the wrong ones, but we might wanna ping the FE folks. 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pinged them, though I'm not expecting these error codes to be especially problematic

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:chefskiss:

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a public API. Not only FE uses it.

"Expected 400 for invalid OrderUid ({description}): {uid}"
);
}

Expand All @@ -76,8 +76,8 @@ async fn http_validation(web3: Web3) {

assert_eq!(
response.status(),
StatusCode::NOT_FOUND,
"Expected 404 for invalid Address ({description}): {addr}"
StatusCode::BAD_REQUEST,
"Expected 400 for invalid Address ({description}): {addr}"
);
}

Expand All @@ -90,8 +90,8 @@ async fn http_validation(web3: Web3) {

assert_eq!(
response.status(),
StatusCode::NOT_FOUND,
"Expected 404 for invalid token Address ({description}): {addr}"
StatusCode::BAD_REQUEST,
"Expected 400 for invalid token Address ({description}): {addr}"
);
}

Expand All @@ -113,19 +113,24 @@ async fn http_validation(web3: Web3) {

assert_eq!(
response.status(),
StatusCode::NOT_FOUND,
"Expected 404 for invalid tx hash ({description}): {hash}"
StatusCode::BAD_REQUEST,
"Expected 400 for invalid tx hash ({description}): {hash}"
);
}

// Test malformed auction IDs
let invalid_auction_ids: Vec<(&str, &str)> = vec![
("not-a-number", "non-numeric"),
("-1", "negative number"),
("99999999999999999999999", "u64 overflow"),
];

for (id, description) in invalid_auction_ids {
// Note: "-1" returns 404 because it doesn't match the u64 route pattern at all,
// while non-numeric strings return 400 as they match the path but fail
// deserialization
for (id, description, expected_status) in [
("not-a-number", "non-numeric", StatusCode::BAD_REQUEST),
("-1", "negative number", StatusCode::NOT_FOUND),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure about it. -1 seems like a bad request since we don't support negative IDs and I assume the openapi doc should clarify this.

Suggested change
("-1", "negative number", StatusCode::NOT_FOUND),
("-1", "negative number", StatusCode::BAD_REQUEST),

(
"99999999999999999999999",
"u64 overflow",
StatusCode::BAD_REQUEST,
),
] {
let response = client
.get(format!("{API_HOST}/api/v1/solver_competition/{id}"))
.send()
Expand All @@ -134,8 +139,8 @@ async fn http_validation(web3: Web3) {

assert_eq!(
response.status(),
StatusCode::NOT_FOUND,
"Expected 404 for invalid AuctionId ({description}): {id}"
expected_status,
"Expected {expected_status} for invalid AuctionId ({description}): {id}"
);
}

Expand Down Expand Up @@ -203,6 +208,7 @@ async fn http_validation(web3: Web3) {
);

// Missing required fields (empty object)
// Axum returns 422 (Unprocessable Entity) for JSON deserialization errors
let response = client
.post(format!("{API_HOST}/api/v1/orders"))
.header("Content-Type", "application/json")
Expand All @@ -213,8 +219,8 @@ async fn http_validation(web3: Web3) {

assert_eq!(
response.status(),
StatusCode::BAD_REQUEST,
"Missing required fields should return 400"
StatusCode::UNPROCESSABLE_ENTITY,
"Missing required fields should return 422"
);

// Wrong field types
Expand All @@ -236,8 +242,8 @@ async fn http_validation(web3: Web3) {

assert_eq!(
response.status(),
StatusCode::BAD_REQUEST,
"Wrong field types should return 400"
StatusCode::UNPROCESSABLE_ENTITY,
"Wrong field types should return 422"
);

// Invalid enum value
Expand All @@ -256,8 +262,8 @@ async fn http_validation(web3: Web3) {

assert_eq!(
response.status(),
StatusCode::BAD_REQUEST,
"Invalid enum value should return 400"
StatusCode::UNPROCESSABLE_ENTITY,
"Invalid enum value should return 422"
);

// Test error response formats
Expand All @@ -270,7 +276,7 @@ async fn http_validation(web3: Web3) {
.await
.unwrap();

assert_eq!(response.status(), StatusCode::BAD_REQUEST);
assert_eq!(response.status(), StatusCode::UNPROCESSABLE_ENTITY);

let body_text = response.text().await.unwrap();
assert!(
Expand Down
4 changes: 2 additions & 2 deletions crates/e2e/tests/e2e/replace_order.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ fn parse_order_replacement_error(status: StatusCode, body: &str) -> Option<Order
let error: ApiError = serde_json::from_str(body).ok()?;

match status {
StatusCode::BAD_REQUEST => match error.error_type {
StatusCode::BAD_REQUEST => match error.error_type.as_str() {
"InvalidSignature" => Some(OrderReplacementError::InvalidSignature),
"OldOrderActivelyBidOn" => Some(OrderReplacementError::OldOrderActivelyBidOn),
_ => None,
Expand All @@ -46,7 +46,7 @@ fn parse_order_cancellation_error(
let error: ApiError = serde_json::from_str(body).ok()?;

match status {
StatusCode::BAD_REQUEST => match error.error_type {
StatusCode::BAD_REQUEST => match error.error_type.as_str() {
"InvalidSignature" => Some(OrderCancellationError::InvalidSignature),
"AlreadyCancelled" => Some(OrderCancellationError::AlreadyCancelled),
"OrderFullyExecuted" => Some(OrderCancellationError::OrderFullyExecuted),
Expand Down
1 change: 0 additions & 1 deletion crates/observe/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ tracing = { workspace = true }
tracing-opentelemetry = { workspace = true }
tracing-subscriber = { workspace = true, features = ["env-filter", "fmt", "time"] }
tracing-serde = { workspace = true }
warp = { workspace = true }
jemalloc_pprof = { workspace = true }

[lints]
Expand Down
1 change: 0 additions & 1 deletion crates/observe/src/distributed_tracing/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
pub mod request_id;
pub mod trace_id_format;
pub mod tracing_axum;
pub mod tracing_warp;
23 changes: 0 additions & 23 deletions crates/observe/src/distributed_tracing/tracing_warp.rs

This file was deleted.

Loading
Loading