From 31e246740c3bfa4ae94c82b30585bccb3f65b748 Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Tue, 13 Aug 2024 22:37:05 +0200 Subject: [PATCH] fix: extend step_id being returned as part of the error of every languages --- backend/windmill-worker/src/worker.rs | 23 +++++++++++++++---- .../lib/components/flows/previousResults.ts | 1 + .../propertyPicker/PropPicker.svelte | 3 ++- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/backend/windmill-worker/src/worker.rs b/backend/windmill-worker/src/worker.rs index fecd551fae..745e3a10ac 100644 --- a/backend/windmill-worker/src/worker.rs +++ b/backend/windmill-worker/src/worker.rs @@ -2170,9 +2170,20 @@ pub async fn handle_job_error Box { +#[derive(Debug, Serialize)] +struct SerializedError { + message: String, + name: String, + #[serde(skip_serializing_if = "Option::is_none")] + step_id: Option, +} +fn extract_error_value(log_lines: &str, i: i32, step_id: Option) -> Box { return to_raw_value( - &json!({"message": format!("ExitCode: {i}, last log lines:\n{}", ANSI_ESCAPE_RE.replace_all(log_lines.trim(), "").to_string()), "name": "ExecutionErr"}), + &SerializedError { + message: format!("ExitCode: {i}, last log lines:\n{}", ANSI_ESCAPE_RE.replace_all(log_lines.trim(), "").to_string()), + name: "ExecutionErr".to_string(), + step_id, + }, ); } @@ -2640,11 +2651,15 @@ async fn process_result( .last() .unwrap_or(&last_10_log_lines); - extract_error_value(log_lines, i) + extract_error_value(log_lines, i, job.flow_step_id.clone()) } } err @ _ => to_raw_value( - &json!({"message": format!("error during execution of the script:\n{}", err), "name": "ExecutionErr"}), + &SerializedError { + message: format!("error during execution of the script:\n{}", err), + name: "ExecutionErr".to_string(), + step_id: job.flow_step_id.clone(), + }, ), }; diff --git a/frontend/src/lib/components/flows/previousResults.ts b/frontend/src/lib/components/flows/previousResults.ts index d17f00c06c..03a96095cc 100644 --- a/frontend/src/lib/components/flows/previousResults.ts +++ b/frontend/src/lib/components/flows/previousResults.ts @@ -155,6 +155,7 @@ declare const error: { message: string name: string stack: string + step_id: string } /** diff --git a/frontend/src/lib/components/propertyPicker/PropPicker.svelte b/frontend/src/lib/components/propertyPicker/PropPicker.svelte index 678d907ead..60bcb0fdea 100644 --- a/frontend/src/lib/components/propertyPicker/PropPicker.svelte +++ b/frontend/src/lib/components/propertyPicker/PropPicker.svelte @@ -113,7 +113,8 @@ error: { message: 'The error message', name: 'The error name', - stack: 'The error stack' + stack: 'The error stack', + step_id: 'The step id' } }} on:select