[Frontend] Add /abort_requests to the RLHF dev API router (#47173)

Signed-off-by: aoshen02 <aoshen@inferact.ai>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
aoshen02
2026-07-12 14:21:02 +08:00
committed by GitHub
co-authored by Claude Opus 4.8 mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
parent a02984ed47
commit 83762b77b0
8 changed files with 69 additions and 12 deletions
+2 -6
View File
@@ -20,12 +20,8 @@ pub async fn abort_requests(
body: Result<Json<AbortRequestsRequest>, JsonRejection>,
) -> Result<StatusCode, ApiError> {
let Json(body) = body.map_err(|error| ApiError::json_parse_error(error.body_text()))?;
let request_ids = body.request_ids.ok_or_else(|| {
ApiError::invalid_request(
"Missing 'request_ids' in request body".to_string(),
Some("request_ids"),
)
})?;
// Empty/missing `request_ids` aborts all in-flight requests.
let request_ids = body.request_ids.unwrap_or_default();
state
.chat
+6 -5
View File
@@ -5276,10 +5276,12 @@ async fn abort_requests_route_returns_ok_for_well_formed_body() {
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
#[serial]
async fn abort_requests_route_rejects_missing_request_ids() {
async fn abort_requests_route_aborts_all_when_request_ids_missing() {
let (app, engine_task) =
test_admin_app_with_engine_script(|_dealer, _push| boxed_test_future(async move {})).await;
// Missing `request_ids` means "abort all in-flight requests"; with no
// in-flight requests this is a no-op that still succeeds.
let response = app
.clone()
.call(
@@ -5293,11 +5295,10 @@ async fn abort_requests_route_rejects_missing_request_ids() {
.await
.expect("call app");
assert_eq!(response.status(), StatusCode::BAD_REQUEST);
let status = response.status();
let body = to_bytes(response.into_body(), usize::MAX).await.expect("read body");
let json: serde_json::Value = serde_json::from_slice(&body).expect("decode json");
assert_eq!(json["error"]["type"], "invalid_request_error");
assert_eq!(json["error"]["param"], "request_ids");
assert_eq!(status, StatusCode::OK, "{}", String::from_utf8_lossy(&body));
assert!(body.is_empty());
engine_task.abort_and_join().await;
}