diff --git a/src/gateway/routes.rs b/src/gateway/routes.rs index 1207165..c26f4e3 100644 --- a/src/gateway/routes.rs +++ b/src/gateway/routes.rs @@ -2288,6 +2288,20 @@ mod tests { assert_eq!(body.get("code"), Some(&json!("INVALID_INPUT"))); } + #[tokio::test] + async fn publish_first_line_invalid_json_returns_400() { + let router = build_router(publish_registry(), unused_provider()); + let req = raw_request("POST", "/publish", b"not-json-at-all\n".to_vec()); + let (status, body) = send(router, req).await; + assert_eq!(status, StatusCode::BAD_REQUEST); + assert_eq!(body.get("code"), Some(&json!("INVALID_INPUT"))); + let message = body.get("message").and_then(Value::as_str).unwrap_or(""); + assert!( + message.contains("not valid JSON"), + "the 400 must name the JSON parse failure: {message}" + ); + } + #[tokio::test] async fn publish_first_line_missing_chunk_returns_400_invalid_input() { let router = build_router(publish_registry(), unused_provider());