From 0e71acf32f93858c514f9cc3325fa6aa2028fade Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 23 Jun 2026 14:47:36 +0200 Subject: [PATCH 1/2] fix: correct function signature --- .../taurus-core/src/runtime/functions/http.rs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/crates/taurus-core/src/runtime/functions/http.rs b/crates/taurus-core/src/runtime/functions/http.rs index 7fbfe09..44d933c 100644 --- a/crates/taurus-core/src/runtime/functions/http.rs +++ b/crates/taurus-core/src/runtime/functions/http.rs @@ -33,17 +33,21 @@ fn respond( _ctx: &mut ValueStore, _run: &mut crate::handler::registry::ThunkRunner<'_>, ) -> Signal { - args!(args => http_status_code: i64, headers: Struct, _http_schema: String, payload: Value); + args!(args => http_status_code: i64, http_schema: String, payload: Value, headers: Value); + + let http_headers = match headers_from_value(&headers) { + Ok(headers) => headers, + Err(signal) => return signal, + }; let mut fields = HashMap::new(); fields.insert("http_status_code".to_string(), http_status_code.to_value()); - fields.insert( - "headers".to_string(), - Value { - kind: Some(Kind::StructValue(headers)), - }, - ); + fields.insert("headers".to_string(), Value { + kind: Some(Kind::StructValue(http_headers)) + }); + fields.insert("payload".to_string(), payload); + fields.insert("http_schema".to_string(), http_schema.to_value()); // `Respond` is a control signal; the executor can still continue with `next` if present. Signal::Respond(Value { From 603b40d07fce7d0a7ce212dd41161477b69a005a Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 23 Jun 2026 14:56:48 +0200 Subject: [PATCH 2/2] feat: adjusted test suite paramter order for new signature of rest control respond --- crates/taurus-core/src/runtime/engine.rs | 13 +-- .../taurus-core/src/runtime/functions/http.rs | 11 ++- crates/taurus/src/app/mod.rs | 7 +- crates/taurus/src/app/worker.rs | 2 +- flows/01_return_object.json | 33 +++---- flows/02_return_flow_input.json | 36 +++---- flows/05_if_control.json | 42 ++++---- flows/06_if_else_control.json | 42 ++++---- flows/07_simple_return.json | 21 ++-- flows/09_filter_return.json | 36 +++---- flows/10_multiple_respond.json | 96 ++++++++++--------- flows/12_for_each_function_subflow.json | 25 ++--- 12 files changed, 189 insertions(+), 175 deletions(-) diff --git a/crates/taurus-core/src/runtime/engine.rs b/crates/taurus-core/src/runtime/engine.rs index af99502..b91b5bd 100644 --- a/crates/taurus-core/src/runtime/engine.rs +++ b/crates/taurus-core/src/runtime/engine.rs @@ -1194,9 +1194,9 @@ mod tests { "rest::control::respond", vec![ literal_param(100, "http_status_code", int_value(200)), - literal_param(101, "headers", empty_struct_value()), literal_param(102, "http_schema", string_value("application/json")), literal_param(103, "payload", string_value("hello")), + literal_param(101, "headers", empty_struct_value()), ], None, ); @@ -1212,15 +1212,15 @@ mod tests { assert_eq!(node_result.parameter_results[0].value, Some(int_value(200))); assert_eq!( node_result.parameter_results[1].value, - Some(empty_struct_value()) + Some(string_value("application/json")) ); assert_eq!( node_result.parameter_results[2].value, - Some(string_value("application/json")) + Some(string_value("hello")) ); assert_eq!( node_result.parameter_results[3].value, - Some(string_value("hello")) + Some(empty_struct_value()) ); assert!(matches!( node_result.result, @@ -1438,9 +1438,9 @@ mod tests { "rest::control::respond", vec![ literal_param(1, "http_status_code", int_value(200)), - literal_param(2, "headers", empty_struct_value()), literal_param(3, "http_schema", string_value("text/plain")), literal_param(4, "payload", string_value("20")), + literal_param(2, "headers", empty_struct_value()), ], None, ); @@ -1480,6 +1480,7 @@ mod tests { fields.insert("http_status_code".to_string(), int_value(200)); fields.insert("headers".to_string(), empty_struct_value()); fields.insert("payload".to_string(), string_value("20")); + fields.insert("http_schema".to_string(), string_value("text/plain")); Value { kind: Some(Kind::StructValue(Struct { fields })), } @@ -1581,9 +1582,9 @@ mod tests { "rest::control::respond", vec![ literal_param(100, "http_status_code", int_value(200)), - literal_param(101, "headers", empty_struct_value()), literal_param(102, "http_schema", string_value("application/json")), literal_param(103, "payload", string_value("hello")), + literal_param(101, "headers", empty_struct_value()), ], Some(2), ); diff --git a/crates/taurus-core/src/runtime/functions/http.rs b/crates/taurus-core/src/runtime/functions/http.rs index 44d933c..39afa52 100644 --- a/crates/taurus-core/src/runtime/functions/http.rs +++ b/crates/taurus-core/src/runtime/functions/http.rs @@ -34,7 +34,7 @@ fn respond( _run: &mut crate::handler::registry::ThunkRunner<'_>, ) -> Signal { args!(args => http_status_code: i64, http_schema: String, payload: Value, headers: Value); - + let http_headers = match headers_from_value(&headers) { Ok(headers) => headers, Err(signal) => return signal, @@ -42,9 +42,12 @@ fn respond( let mut fields = HashMap::new(); fields.insert("http_status_code".to_string(), http_status_code.to_value()); - fields.insert("headers".to_string(), Value { - kind: Some(Kind::StructValue(http_headers)) - }); + fields.insert( + "headers".to_string(), + Value { + kind: Some(Kind::StructValue(http_headers)), + }, + ); fields.insert("payload".to_string(), payload); fields.insert("http_schema".to_string(), http_schema.to_value()); diff --git a/crates/taurus/src/app/mod.rs b/crates/taurus/src/app/mod.rs index 78a341b..ed2d126 100644 --- a/crates/taurus/src/app/mod.rs +++ b/crates/taurus/src/app/mod.rs @@ -28,11 +28,8 @@ pub async fn run() { let client = connect_nats(&config).await; let mut health_task = spawn_health_task(&config); - let ( - runtime_status_service, - runtime_execution_service, - mut runtime_status_heartbeat_task, - ) = setup_dynamic_services_if_needed(&config).await; + let (runtime_status_service, runtime_execution_service, mut runtime_status_heartbeat_task) = + setup_dynamic_services_if_needed(&config).await; let nats_remote = NATSRemoteRuntime::new(client.clone()); let runtime_emitter = NATSRespondEmitter::new(client.clone()); diff --git a/crates/taurus/src/app/worker.rs b/crates/taurus/src/app/worker.rs index f45211e..2f7469a 100644 --- a/crates/taurus/src/app/worker.rs +++ b/crates/taurus/src/app/worker.rs @@ -176,7 +176,7 @@ async fn execute_flow( input, signal: report.signal, node_execution_results: report.node_execution_results, - } + } } fn parse_execution_id_from_subject( diff --git a/flows/01_return_object.json b/flows/01_return_object.json index 4892843..cb38f1c 100644 --- a/flows/01_return_object.json +++ b/flows/01_return_object.json @@ -9,7 +9,8 @@ "headers": { "Header": "X" }, - "payload": "Hello World" + "payload": "Hello World", + "http_schema": "application/json" } } ], @@ -32,21 +33,6 @@ } } }, - { - "databaseId": "2", - "runtimeParameterId": "headers", - "value": { - "literalValue": { - "structValue": { - "fields": { - "Header": { - "stringValue": "X" - } - } - } - } - } - }, { "databaseId": "4", "runtimeParameterId": "http_schema", @@ -64,6 +50,21 @@ "stringValue": "Hello World" } } + }, + { + "databaseId": "2", + "runtimeParameterId": "headers", + "value": { + "literalValue": { + "structValue": { + "fields": { + "Header": { + "stringValue": "X" + } + } + } + } + } } ] } diff --git a/flows/02_return_flow_input.json b/flows/02_return_flow_input.json index 535fae5..b0839eb 100644 --- a/flows/02_return_flow_input.json +++ b/flows/02_return_flow_input.json @@ -9,7 +9,8 @@ "headers": { "Authentication": "X" }, - "payload": null + "payload": null, + "http_schema": "application/json" } }, { @@ -35,7 +36,8 @@ "cat", "bird" ] - } + }, + "http_schema": "application/json" } } ], @@ -60,21 +62,6 @@ } } }, - { - "databaseId": "6", - "runtimeParameterId": "headers", - "value": { - "literalValue": { - "structValue": { - "fields": { - "Authentication": { - "stringValue": "X" - } - } - } - } - } - }, { "databaseId": "8", "runtimeParameterId": "http_schema", @@ -92,6 +79,21 @@ "flowInput": {} } } + }, + { + "databaseId": "6", + "runtimeParameterId": "headers", + "value": { + "literalValue": { + "structValue": { + "fields": { + "Authentication": { + "stringValue": "X" + } + } + } + } + } } ] } diff --git a/flows/05_if_control.json b/flows/05_if_control.json index 5f265f9..7cea314 100644 --- a/flows/05_if_control.json +++ b/flows/05_if_control.json @@ -30,7 +30,8 @@ "expected_result": { "http_status_code": 200, "headers": {}, - "payload": "Blub" + "payload": "Blub", + "http_schema": "application/json" } }, { @@ -46,7 +47,8 @@ "expected_result": { "http_status_code": 200, "headers": {}, - "payload": "Blub" + "payload": "Blub", + "http_schema": "application/json" } } ], @@ -87,15 +89,6 @@ } } }, - { - "databaseId": "55", - "runtimeParameterId": "headers", - "value": { - "literalValue": { - "structValue": {} - } - } - }, { "databaseId": "57", "runtimeParameterId": "http_schema", @@ -113,6 +106,15 @@ "stringValue": "Blub" } } + }, + { + "databaseId": "55", + "runtimeParameterId": "headers", + "value": { + "literalValue": { + "structValue": {} + } + } } ] }, @@ -166,15 +168,6 @@ } } }, - { - "databaseId": "52", - "runtimeParameterId": "headers", - "value": { - "literalValue": { - "structValue": {} - } - } - }, { "databaseId": "54", "runtimeParameterId": "http_schema", @@ -200,6 +193,15 @@ "flowInput": {} } } + }, + { + "databaseId": "52", + "runtimeParameterId": "headers", + "value": { + "literalValue": { + "structValue": {} + } + } } ] } diff --git a/flows/06_if_else_control.json b/flows/06_if_else_control.json index 20b8dd2..37b2d2b 100644 --- a/flows/06_if_else_control.json +++ b/flows/06_if_else_control.json @@ -30,7 +30,8 @@ "expected_result": { "http_status_code": 200, "headers": {}, - "payload": "Blub" + "payload": "Blub", + "http_schema": "application/json" } }, { @@ -46,7 +47,8 @@ "expected_result": { "http_status_code": 200, "headers": {}, - "payload": "Blob" + "payload": "Blob", + "http_schema": "application/json" } } ], @@ -87,15 +89,6 @@ } } }, - { - "databaseId": "78", - "runtimeParameterId": "headers", - "value": { - "literalValue": { - "structValue": {} - } - } - }, { "databaseId": "80", "runtimeParameterId": "http_schema", @@ -113,6 +106,15 @@ "stringValue": "Blub" } } + }, + { + "databaseId": "78", + "runtimeParameterId": "headers", + "value": { + "literalValue": { + "structValue": {} + } + } } ] }, @@ -176,15 +178,6 @@ } } }, - { - "databaseId": "73", - "runtimeParameterId": "headers", - "value": { - "literalValue": { - "structValue": {} - } - } - }, { "databaseId": "76", "runtimeParameterId": "http_schema", @@ -202,6 +195,15 @@ "stringValue": "Blob" } } + }, + { + "databaseId": "73", + "runtimeParameterId": "headers", + "value": { + "literalValue": { + "structValue": {} + } + } } ] } diff --git a/flows/07_simple_return.json b/flows/07_simple_return.json index fd8d958..0cf713c 100644 --- a/flows/07_simple_return.json +++ b/flows/07_simple_return.json @@ -23,7 +23,8 @@ null, null, "username" - ] + ], + "http_schema": "application/json" } } ], @@ -203,15 +204,6 @@ } } }, - { - "databaseId": "36", - "runtimeParameterId": "headers", - "value": { - "literalValue": { - "structValue": {} - } - } - }, { "databaseId": "38", "runtimeParameterId": "http_schema", @@ -229,6 +221,15 @@ "nodeId": "9" } } + }, + { + "databaseId": "36", + "runtimeParameterId": "headers", + "value": { + "literalValue": { + "structValue": {} + } + } } ] } diff --git a/flows/09_filter_return.json b/flows/09_filter_return.json index 1fd6a1e..ca4d0ba 100644 --- a/flows/09_filter_return.json +++ b/flows/09_filter_return.json @@ -41,7 +41,8 @@ "payload": [ "timmy doe", "willy wokner" - ] + ], + "http_schema": "application/json" } }, { @@ -70,7 +71,8 @@ "x": "y" }, "http_status_code": 200, - "payload": [] + "payload": [], + "http_schema": "application/json" } } ], @@ -330,21 +332,6 @@ } } }, - { - "databaseId": "30", - "runtimeParameterId": "headers", - "value": { - "literalValue": { - "structValue": { - "fields": { - "x": { - "stringValue": "y" - } - } - } - } - } - }, { "databaseId": "32", "runtimeParameterId": "http_schema", @@ -362,6 +349,21 @@ "nodeId": "10" } } + }, + { + "databaseId": "30", + "runtimeParameterId": "headers", + "value": { + "literalValue": { + "structValue": { + "fields": { + "x": { + "stringValue": "y" + } + } + } + } + } } ] } diff --git a/flows/10_multiple_respond.json b/flows/10_multiple_respond.json index 033ceb0..67f9b4e 100644 --- a/flows/10_multiple_respond.json +++ b/flows/10_multiple_respond.json @@ -41,7 +41,8 @@ "payload": [ "timmy doe", "willy wokner" - ] + ], + "http_schema": "application/json" } }, { @@ -57,7 +58,8 @@ "x": "y" }, "http_status_code": 200, - "payload": [] + "payload": [], + "http_schema": "application/json" } } ], @@ -317,21 +319,6 @@ } } }, - { - "databaseId": "30", - "runtimeParameterId": "headers", - "value": { - "literalValue": { - "structValue": { - "fields": { - "x": { - "stringValue": "y" - } - } - } - } - } - }, { "databaseId": "32", "runtimeParameterId": "http_schema", @@ -349,6 +336,21 @@ "nodeId": "10" } } + }, + { + "databaseId": "30", + "runtimeParameterId": "headers", + "value": { + "literalValue": { + "structValue": { + "fields": { + "x": { + "stringValue": "y" + } + } + } + } + } } ], "nextNodeId": "20" @@ -369,21 +371,6 @@ } } }, - { - "databaseId": "30", - "runtimeParameterId": "headers", - "value": { - "literalValue": { - "structValue": { - "fields": { - "x": { - "stringValue": "y" - } - } - } - } - } - }, { "databaseId": "32", "runtimeParameterId": "http_schema", @@ -401,6 +388,21 @@ "nodeId": "10" } } + }, + { + "databaseId": "30", + "runtimeParameterId": "headers", + "value": { + "literalValue": { + "structValue": { + "fields": { + "x": { + "stringValue": "y" + } + } + } + } + } } ] }, @@ -420,21 +422,6 @@ } } }, - { - "databaseId": "30", - "runtimeParameterId": "headers", - "value": { - "literalValue": { - "structValue": { - "fields": { - "x": { - "stringValue": "y" - } - } - } - } - } - }, { "databaseId": "32", "runtimeParameterId": "http_schema", @@ -452,6 +439,21 @@ "nodeId": "10" } } + }, + { + "databaseId": "30", + "runtimeParameterId": "headers", + "value": { + "literalValue": { + "structValue": { + "fields": { + "x": { + "stringValue": "y" + } + } + } + } + } } ] }, diff --git a/flows/12_for_each_function_subflow.json b/flows/12_for_each_function_subflow.json index 17922c9..3fada16 100644 --- a/flows/12_for_each_function_subflow.json +++ b/flows/12_for_each_function_subflow.json @@ -7,7 +7,8 @@ "expected_result": { "http_status_code": 200, "headers": {}, - "payload": "20" + "payload": "20", + "http_schema": "application/json" } } ], @@ -31,17 +32,6 @@ } } }, - { - "databaseId": "2", - "runtimeParameterId": "headers", - "value": { - "literalValue": { - "structValue": { - "fields": {} - } - } - } - }, { "databaseId": "4", "runtimeParameterId": "http_schema", @@ -59,6 +49,17 @@ "stringValue": "20" } } + }, + { + "databaseId": "2", + "runtimeParameterId": "headers", + "value": { + "literalValue": { + "structValue": { + "fields": {} + } + } + } } ], "definitionSource": "draco-draco-cron"