From 2d2e351dbd3414d760be20803f7e5fb03b62209b Mon Sep 17 00:00:00 2001 From: dayan02dev Date: Tue, 17 Nov 2026 22:28:50 +0000 Subject: [PATCH] fix(servers): report the dryrun row limit instead of "data is required" (#10491) * test(servers): expect the dryrun row limit in the error message Signed-off-by: dayan02dev * fix(servers): report the dryrun row limit instead of "data is required" Signed-off-by: dayan02dev --------- Signed-off-by: dayan02dev --- src/servers/src/http/event.rs | 20 ++++++++++++++--- tests-integration/tests/http.rs | 39 +++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 3 deletions(-) diff --git a/src/servers/src/http/event.rs b/src/servers/src/http/event.rs index 2470080c1b4..ef2b557ff08 100644 --- a/src/servers/src/http/event.rs +++ b/src/servers/src/http/event.rs @@ -571,12 +571,15 @@ fn check_pipeline_name_exists(pipeline_name: Option) -> Result { }) } -/// Check if the data length less than 10 +/// The maximum number of rows the pipeline dryrun API accepts. +const MAX_DRYRUN_ROWS: usize = 10; + +/// Check that the dryrun data has at most [`MAX_DRYRUN_ROWS`] rows. fn check_data_valid(data_len: usize) -> Result<()> { ensure!( - data_len <= 10, + data_len <= MAX_DRYRUN_ROWS, InvalidParameterSnafu { - reason: "data is required", + reason: format!("dryrun data must not exceed {MAX_DRYRUN_ROWS} rows, got {data_len}"), } ); Ok(()) @@ -1124,6 +1127,17 @@ mod tests { use super::*; + #[test] + fn test_check_data_valid() { + assert!(check_data_valid(0).is_ok()); + assert!(check_data_valid(10).is_ok()); + let err = check_data_valid(11).unwrap_err(); + assert_eq!( + err.output_msg(), + "Invalid request parameter: dryrun data must not exceed 10 rows, got 11" + ); + } + #[test] fn test_transform_ndjson() { let s = "{\"a\": 1}\n{\"b\": 2}"; diff --git a/tests-integration/tests/http.rs b/tests-integration/tests/http.rs index f044e91cc09..5ed746ed3b0 100644 --- a/tests-integration/tests/http.rs +++ b/tests-integration/tests/http.rs @@ -8446,6 +8446,45 @@ transform: .await; assert_eq!(res.status(), StatusCode::BAD_REQUEST); } + { + // the dryrun API accepts at most 10 rows + let rows = (0..11) + .map(|i| { + json!({ + "id1": "2436", + "id2": "2528", + "logger": "INTERACT.MANAGER", + "type": "I", + "time": "2024-05-25 20:16:37.217", + "log": format!("row {i}") + }) + }) + .collect::>(); + let data = Value::Array(rows).to_string(); + let expected = + json!("Invalid request parameter: dryrun data must not exceed 10 rows, got 11"); + + let body = json!({"pipeline_name": "test", "data": data}); + let res = client + .post("/v1/pipelines/_dryrun") + .header("Content-Type", "application/json") + .body(body.to_string()) + .send() + .await; + assert_eq!(res.status(), StatusCode::BAD_REQUEST); + let body: Value = res.json().await; + assert_eq!(body["error"], expected); + + let res = client + .post("/v1/pipelines/_dryrun?pipeline_name=test") + .header("Content-Type", "application/json") + .body(data) + .send() + .await; + assert_eq!(res.status(), StatusCode::BAD_REQUEST); + let body: Value = res.json().await; + assert_eq!(body["error"], expected); + } guard.remove_all().await; }