From abf63a6560817cfd392d3df7a74ba937255cb507 Mon Sep 17 00:00:00 2001 From: Lucas Abel <22837557+uael@users.noreply.github.com> Date: Mon, 6 Jan 2025 09:21:17 +0100 Subject: [PATCH] fix(backend): fix `has_failure_module` only looking for `raw_flow` (#5018) --- backend/windmill-queue/src/jobs.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/backend/windmill-queue/src/jobs.rs b/backend/windmill-queue/src/jobs.rs index a99f9a3fcfae5..aea0096216ce9 100644 --- a/backend/windmill-queue/src/jobs.rs +++ b/backend/windmill-queue/src/jobs.rs @@ -900,11 +900,14 @@ pub async fn add_completed_job( #[cfg(feature = "enterprise")] if !success { - async fn has_failure_module(db: &Pool, job_id: Uuid) -> bool { - sqlx::query_scalar!("SELECT raw_flow->'failure_module' != 'null'::jsonb FROM job WHERE id = $1", job_id) + async fn has_failure_module(db: &Pool, job: &QueuedJob) -> bool { + if let Ok(flow) = cache::job::fetch_flow(db, job.job_kind, job.script_hash).await { + return flow.value().failure_module.is_some(); + } + sqlx::query_scalar!("SELECT raw_flow->'failure_module' != 'null'::jsonb FROM job WHERE id = $1", job.id) .fetch_one(db) .or_else(|_| - sqlx::query_scalar!("SELECT raw_flow->'failure_module' != 'null'::jsonb FROM completed_job WHERE id = $1", job_id) + sqlx::query_scalar!("SELECT raw_flow->'failure_module' != 'null'::jsonb FROM completed_job WHERE id = $1", job.id) .fetch_one(db) ) .await @@ -952,7 +955,7 @@ pub async fn add_completed_job( } else if !_skip_downstream_error_handlers && (matches!(queued_job.job_kind, JobKind::Script) || matches!(queued_job.job_kind, JobKind::Flow) - && !has_failure_module(db, _job_id).await) + && !has_failure_module(db, queued_job).await) && queued_job.parent_job.is_none() { let result = serde_json::from_str(