feat: show a flow's continue-on-error failures on its run and status (#12525)

* feat: show a flow's continue-on-error failures on its run and status

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: record continued failures after the flow's row and render jobless ones as text

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: keep the share link's view token on failed-step links

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Ruben Fiszel
2026-11-18 22:53:19 +01:00
committed by GitHub
co-authored by Claude Opus 5.5
parent a718720fd6
commit 71e7d9e440
8 changed files with 213 additions and 13 deletions
@@ -0,0 +1,16 @@
{
"db_name": "PostgreSQL",
"query": "UPDATE v2_job_status\n SET flow_status = JSONB_SET(\n flow_status,\n ARRAY['continued_on_error'],\n COALESCE(flow_status->'continued_on_error', '[]'::jsonb) || JSONB_BUILD_ARRAY($2::jsonb)\n )\n WHERE id = $1\n AND flow_status IS NOT NULL\n AND JSONB_ARRAY_LENGTH(COALESCE(flow_status->'continued_on_error', '[]'::jsonb)) < $3",
"describe": {
"columns": [],
"parameters": {
"Left": [
"Uuid",
"Jsonb",
"Int4"
]
},
"nullable": []
},
"hash": "4c260718afc95b83abd83daca83361b028471ba1bfe2fc45a7dc2914f059c9c3"
}
+55
View File
@@ -4852,6 +4852,61 @@ async fn test_unrecoverable_failure_on_continue_on_error_runs_failure_module(
Ok(())
}
/// A failure the flow goes past because of `continue_on_error` is recorded on the root flow's
/// status, including one inside a loop iteration's subflow.
#[cfg(feature = "deno_core")]
#[sqlx::test(fixtures("base"))]
async fn test_continue_on_error_recorded_on_root(db: Pool<Postgres>) -> anyhow::Result<()> {
initialize_tracing().await;
let server = ApiServer::start(db.clone()).await?;
let port = server.addr.port();
let failing = |id: &str| {
json!({"id": id, "continue_on_error": true, "value": {
"type": "rawscript", "language": "bun", "input_transforms": {},
"content": "export function main() { throw new Error('boom'); }",
}})
};
let flow: FlowValue = serde_json::from_value(json!({
"modules": [
failing("a"),
{"id": "loop", "value": {
"type": "forloopflow", "parallel": true, "skip_failures": false,
"iterator": {"type": "static", "value": [1, 2]},
"modules": [failing("b"), {"id": "c", "value": {"type": "identity"}}],
}},
],
}))
.unwrap();
let job = RunJob::from(JobPayload::RawFlow { value: flow, path: None, restarted_from: None })
.run_until_complete(&db, false, port)
.await;
server.close().await.unwrap();
assert!(job.success, "{:?}", job.json_result());
let mut recorded: Vec<(String, Uuid, Option<Uuid>)> = sqlx::query_as(
"SELECT e->>'id', (e->>'job')::uuid, j.parent_job
FROM v2_job_completed c, JSONB_ARRAY_ELEMENTS(c.flow_status->'continued_on_error') e
JOIN v2_job j ON j.id = (e->>'job')::uuid
WHERE c.id = $1",
)
.bind(job.id)
.fetch_all(&db)
.await?;
recorded.sort();
let ids: Vec<&str> = recorded.iter().map(|(id, ..)| id.as_str()).collect();
assert_eq!(ids, vec!["a", "b", "b"]);
assert_eq!(recorded[0].2, Some(job.id));
assert_ne!(recorded[1].1, recorded[2].1);
assert_ne!(
recorded[1].2,
Some(job.id),
"b runs in an iteration's subflow"
);
Ok(())
}
#[cfg(feature = "deno_core")]
#[sqlx::test(fixtures("base"))]
async fn test_run_wait_result_early_return_with_failure_module(
+2
View File
@@ -7397,6 +7397,7 @@ async fn push_inner<'c, 'd>(
chat_input_enabled: None,
memory_id: None,
no_inherited_flow_env: false,
continued_on_error: vec![],
}
}
_ => {
@@ -7797,6 +7798,7 @@ async fn push_inner<'c, 'd>(
chat_input_enabled: None,
memory_id: None,
no_inherited_flow_env: false,
continued_on_error: vec![],
};
// The completed job's own scopes are gone with its `job_perms` row, so the restart
// takes the flow's current setting (and the restarting caller's ceiling).
+13
View File
@@ -46,6 +46,18 @@ pub struct FlowStatus {
/// the worker then walks the ancestors as usual.
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
pub no_inherited_flow_env: bool,
/// On a root flow: the steps, at any depth, that failed and that the flow went past
/// because of `continue_on_error`. Capped at `MAX_CONTINUED_ON_ERROR` entries.
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub continued_on_error: Vec<ContinuedOnError>,
}
pub const MAX_CONTINUED_ON_ERROR: i32 = 100;
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct ContinuedOnError {
pub id: String,
pub job: Uuid,
}
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
@@ -633,6 +645,7 @@ impl FlowStatus {
chat_input_enabled: f.chat_input_enabled,
memory_id: None,
no_inherited_flow_env: false,
continued_on_error: vec![],
}
}
+46 -1
View File
@@ -39,7 +39,7 @@ use windmill_common::client::AuthedClient;
use windmill_common::db::Authed;
use windmill_common::flow_conversations::{add_message_to_conversation_tx, MessageType};
use windmill_common::flow_status::{
ApprovalConditions, FlowJobDuration, FlowJobsDuration, FlowStatusModuleWParent,
ApprovalConditions, ContinuedOnError, MAX_CONTINUED_ON_ERROR, FlowJobDuration, FlowJobsDuration, FlowStatusModuleWParent,
Iterator as FlowIterator, JobResult,
};
use windmill_common::flows::{add_virtual_items_if_necessary, Branch, FlowNodeId, StopAfterIf};
@@ -844,6 +844,7 @@ pub async fn update_flow_status_after_job_completion_internal(
add_time!(bench, "process module status START");
let mut nresult = None;
let mut continued_on_error = None;
let (inc_step_counter, new_status) = match module_status {
FlowStatusModule::InProgress {
iterator,
@@ -1415,6 +1416,12 @@ pub async fn update_flow_status_after_job_completion_internal(
} else {
false
};
if inc {
continued_on_error = Some(ContinuedOnError {
id: module_status.id(),
job: *job_id_for_status,
});
}
if (stop_early && stop_early_err_msg.is_some()) || loop_exhausted_err.is_some()
{
// if stop_early with error message, we need to set explictely success to false as this function was called with success = true as the job succeeded
@@ -1614,6 +1621,12 @@ pub async fn update_flow_status_after_job_completion_internal(
.map_err(|e| Error::internal_err(format!("error while setting leaf jobs: {e:#}")))?;
}
// Written after the flow's own row, keeping the child-to-ancestor lock order of
// every flow completion.
if let (Some(entry), Some(flow_job)) = (continued_on_error, flow_job.as_ref()) {
record_continued_on_error(&mut tx, get_root_job_id(flow_job), entry).await?;
}
flow_job
};
@@ -2498,6 +2511,38 @@ async fn set_success_and_duration_in_flow_job_success<'c>(
Ok(())
}
/// Records on the root flow a step that failed and that its flow went past because of
/// `continue_on_error`, so that the failure shows on the root run without expanding the
/// subflow it happened in.
async fn record_continued_on_error(
tx: &mut Transaction<'_, Postgres>,
root: Uuid,
entry: ContinuedOnError,
) -> error::Result<()> {
sqlx::query!(
"UPDATE v2_job_status
SET flow_status = JSONB_SET(
flow_status,
ARRAY['continued_on_error'],
COALESCE(flow_status->'continued_on_error', '[]'::jsonb) || JSONB_BUILD_ARRAY($2::jsonb)
)
WHERE id = $1
AND flow_status IS NOT NULL
AND JSONB_ARRAY_LENGTH(COALESCE(flow_status->'continued_on_error', '[]'::jsonb)) < $3",
root,
json!(entry),
MAX_CONTINUED_ON_ERROR,
)
.execute(&mut **tx)
.await
.map_err(|e| {
Error::internal_err(format!(
"error while recording continued_on_error on root flow {root}: {e:#}"
))
})?;
Ok(())
}
/// Applies a step's edits to the flow's `v2_job_status` row and reads the flow back, in one
/// statement: every UPDATE of that row writes a new row version carrying the whole
/// `flow_status`, so the edits must not be split. `leaf_job` is only written here when the flow
@@ -1470,6 +1470,8 @@
let totalEventsWaiting = $derived(
Object.values(suspendStatus?.val ?? {}).reduce((a, b) => a + (b?.nb ?? 0), 0)
)
let continuedOnError = $derived(job?.flow_status?.continued_on_error ?? [])
</script>
<JobLoader workspaceOverride={workspaceId} {noLogs} noCode bind:this={jobLoader} />
@@ -1484,6 +1486,36 @@
{:else}
<div class="h-8" />
{/if} -->
{#if !isListJob && continuedOnError.length > 0}
<Alert
type="warning"
size="xs"
title="{continuedOnError.length}{continuedOnError.length >= 100
? '+'
: ''} step{continuedOnError.length > 1
? 's'
: ''} failed, the flow continued because of continue on error"
>
<div class="flex flex-wrap gap-x-3 gap-y-1">
<!-- A failure raised before its step's job was created (e.g. a branch predicate
error) carries the nil uuid, so entries are keyed by position. -->
{#each continuedOnError as failure, i (i)}
{#if isReplay || failure.job == '00000000-0000-0000-0000-000000000000'}
<span>{failure.id}</span>
{:else}
<a
rel="noreferrer"
target="_blank"
href={appendViewToken(`/run/${failure.job}?workspace=${job?.workspace_id}`)}
>
{failure.id}
<ExternalLink size={12} class="inline-block" />
</a>
{/if}
{/each}
</div>
</Alert>
{/if}
{#if isListJob}
{#if render}
<div class="w-full border rounded-sm bg-surface p-1 overflow-auto max-h-[90vh]">
+35 -12
View File
@@ -17,20 +17,42 @@
}
let { job, large = false }: Props = $props()
let continuedOnError = $derived(job?.flow_status?.continued_on_error ?? [])
</script>
{#snippet continuedOnErrorBadge()}
{#if continuedOnError.length > 0}
<Badge
{large}
color="orange"
title="Failed steps skipped by continue on error: {continuedOnError
.map((f) => f.id)
.join(', ')}"
>
{continuedOnError.length}{continuedOnError.length >= 100 ? '+' : ''} failed step{continuedOnError.length >
1
? 's'
: ''} continued
</Badge>
{/if}
{/snippet}
{#if job && 'success' in job && job.success}
<Badge {large} color="green">
Successfully ran in {msToReadableTime(job.duration_ms)}
{job.is_skipped ? '(Skipped)' : ''}
{#if job.self_wait_time_ms || job.aggregate_wait_time_ms}
<WaitTimeWarning
self_wait_time_ms={job.self_wait_time_ms}
aggregate_wait_time_ms={job.aggregate_wait_time_ms}
variant="alert"
/>
{/if}
</Badge>
<div class="flex flex-row flex-wrap gap-1 items-center">
<Badge {large} color="green">
Successfully ran in {msToReadableTime(job.duration_ms)}
{job.is_skipped ? '(Skipped)' : ''}
{#if job.self_wait_time_ms || job.aggregate_wait_time_ms}
<WaitTimeWarning
self_wait_time_ms={job.self_wait_time_ms}
aggregate_wait_time_ms={job.aggregate_wait_time_ms}
variant="alert"
/>
{/if}
</Badge>
{@render continuedOnErrorBadge()}
</div>
{:else if job && 'success' in job && job.resolved}
<Badge {large} color="orange" title={job.resolution_note}>
<!-- `resolved_by` is absent both for an automatic resolution and for a manual one
@@ -69,13 +91,14 @@
</Badge>
</div>
{:else if job && 'running' in job && job.running}
<div>
<div class="flex flex-row flex-wrap gap-1 items-center">
<Badge {large} color="yellow">
Running
{#if job.flow_status}
({(job.flow_status?.step ?? 0) + 1} of {job.raw_flow?.modules?.length ?? '?'})
{/if}
</Badge>
{@render continuedOnErrorBadge()}
</div>
{:else if job && 'running' in job && 'scheduled_for' in job && job.scheduled_for && forLater(job.scheduled_for)}
<div>
+14
View File
@@ -1412,6 +1412,20 @@ components:
items:
type: string
format: uuid
continued_on_error:
type: array
description: On a root flow, the steps at any depth that failed and that the flow went past because of continue_on_error (at most 100).
items:
type: object
properties:
id:
type: string
job:
type: string
format: uuid
required:
- id
- job
required:
- step
- modules