diff --git a/beacon_node/http_api/src/lib.rs b/beacon_node/http_api/src/lib.rs index 8c3902fcd4d..159a3d2f041 100644 --- a/beacon_node/http_api/src/lib.rs +++ b/beacon_node/http_api/src/lib.rs @@ -388,12 +388,10 @@ pub fn serve( let beacon_states_path = eth1_v1 .and(warp::path("beacon")) .and(warp::path("states")) - .and(warp::path::param::().or_else(|_| { - blocking_task(|| { - Err(warp_utils::reject::custom_bad_request( - "Invalid state ID".to_string(), - )) - }) + .and(warp::path::param::().or_else(|_| async { + Err(warp_utils::reject::custom_bad_request( + "Invalid state ID".to_string(), + )) })) .and(chain_filter.clone()); @@ -551,7 +549,11 @@ pub fn serve( let get_beacon_state_validators_id = beacon_states_path .clone() .and(warp::path("validators")) - .and(warp::path::param::()) + .and(warp::path::param::().or_else(|_| async { + Err(warp_utils::reject::custom_bad_request( + "Invalid validator ID".to_string(), + )) + })) .and(warp::path::end()) .and_then( |state_id: StateId, chain: Arc>, validator_id: ValidatorId| { @@ -760,7 +762,11 @@ pub fn serve( let get_beacon_headers_block_id = eth1_v1 .and(warp::path("beacon")) .and(warp::path("headers")) - .and(warp::path::param::()) + .and(warp::path::param::().or_else(|_| async { + Err(warp_utils::reject::custom_bad_request( + "Invalid block ID".to_string(), + )) + })) .and(warp::path::end()) .and(chain_filter.clone()) .and_then(|block_id: BlockId, chain: Arc>| { @@ -845,7 +851,11 @@ pub fn serve( let beacon_blocks_path = eth1_v1 .and(warp::path("beacon")) .and(warp::path("blocks")) - .and(warp::path::param::()) + .and(warp::path::param::().or_else(|_| async { + Err(warp_utils::reject::custom_bad_request( + "Invalid block ID".to_string(), + )) + })) .and(chain_filter.clone()); // GET beacon/blocks/{block_id} @@ -1222,7 +1232,11 @@ pub fn serve( .and(warp::path("debug")) .and(warp::path("beacon")) .and(warp::path("states")) - .and(warp::path::param::()) + .and(warp::path::param::().or_else(|_| async { + Err(warp_utils::reject::custom_bad_request( + "Invalid state ID".to_string(), + )) + })) .and(warp::path::end()) .and(chain_filter.clone()) .and_then(|state_id: StateId, chain: Arc>| { @@ -1531,7 +1545,11 @@ pub fn serve( .and(warp::path("validator")) .and(warp::path("duties")) .and(warp::path("proposer")) - .and(warp::path::param::()) + .and(warp::path::param::().or_else(|_| async { + Err(warp_utils::reject::custom_bad_request( + "Invalid epoch".to_string(), + )) + })) .and(warp::path::end()) .and(not_while_syncing_filter.clone()) .and(chain_filter.clone()) @@ -1596,7 +1614,11 @@ pub fn serve( let get_validator_blocks = eth1_v1 .and(warp::path("validator")) .and(warp::path("blocks")) - .and(warp::path::param::()) + .and(warp::path::param::().or_else(|_| async { + Err(warp_utils::reject::custom_bad_request( + "Invalid slot".to_string(), + )) + })) .and(warp::path::end()) .and(not_while_syncing_filter.clone()) .and(warp::query::()) @@ -1683,7 +1705,11 @@ pub fn serve( .and(warp::path("validator")) .and(warp::path("duties")) .and(warp::path("attester")) - .and(warp::path::param::()) + .and(warp::path::param::().or_else(|_| async { + Err(warp_utils::reject::custom_bad_request( + "Invalid epoch".to_string(), + )) + })) .and(warp::path::end()) .and(not_while_syncing_filter.clone()) .and(warp::body::json())