Skip to content

Commit

Permalink
do not call workspace error handler if flow has error handler (#4434)
Browse files Browse the repository at this point in the history
* do not call workspace error handler if flow has error handler

* optimize + UI improvements for error handler
  • Loading branch information
HugoCasa committed Sep 25, 2024
1 parent 8b7bbe8 commit 8a277a0
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 13 deletions.
17 changes: 16 additions & 1 deletion backend/windmill-queue/src/jobs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,11 @@ where
}
}

#[derive(Deserialize)]
struct RawFlowFailureModule {
failure_module: Option<Box<RawValue>>,
}

#[instrument(level = "trace", skip_all)]
pub async fn add_completed_job_error<R: rsmq_async::RsmqConnection + Clone + Send>(
db: &Pool<Postgres>,
Expand Down Expand Up @@ -922,7 +927,17 @@ pub async fn add_completed_job<
)
.await;
} else if !skip_downstream_error_handlers
&& matches!(queued_job.job_kind, JobKind::Flow | JobKind::Script)
&& (matches!(queued_job.job_kind, JobKind::Script)
|| matches!(queued_job.job_kind, JobKind::Flow)
&& queued_job
.raw_flow
.as_ref()
.and_then(|v| {
serde_json::from_str::<RawFlowFailureModule>((**v).get())
.ok()
.and_then(|v| v.failure_module)
})
.is_none())
&& queued_job.parent_job.is_none()
{
let result = serde_json::from_str(
Expand Down
10 changes: 8 additions & 2 deletions frontend/src/lib/components/FlowGraphViewer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,14 @@
failureModule={flow?.value?.failure_module}
preprocessorModule={flow?.value?.preprocessor_module}
on:select={(e) => {
const mod = dfs(flow?.value?.modules ?? [], (m) => m).find((m) => m?.id === e?.detail)
stepDetail = mod ?? e.detail
if (e?.detail === 'failure') {
stepDetail = flow?.value?.failure_module
} else if (e?.detail === 'preprocessor') {
stepDetail = flow?.value?.preprocessor_module
} else {
stepDetail = dfs(flow?.value?.modules ?? [], (m) => m).find((m) => m?.id === e?.detail)
}
stepDetail = stepDetail ?? e?.detail
dispatch('select', stepDetail)
}}
/>
Expand Down
33 changes: 23 additions & 10 deletions frontend/src/lib/components/FlowGraphViewerStep.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,17 @@
{:else if typeof stepDetail != 'string' && stepDetail.value}
<div class="">
<div class="sticky top-0 bg-surface w-full flex items-center py-2">
{#if stepDetail.id}
{#if stepDetail.id && stepDetail.id != 'failure' && stepDetail.id != 'preprocessor'}
<Badge color="indigo">
{stepDetail.id}
</Badge>
{/if}
<span class="ml-2 font-medium text-lg">
<span
class={twMerge(
'font-medium text-lg',
stepDetail.id !== 'failure' && stepDetail.id !== 'preprocessor' ? 'ml-2' : ''
)}
>
{#if stepDetail.summary}
{stepDetail.summary}
{:else if stepDetail.value.type == 'identity'}
Expand All @@ -124,6 +129,10 @@
Inner flow
{:else if stepDetail.value.type == 'whileloopflow'}
While loop
{:else if stepDetail.id === 'failure'}
Error handler
{:else if stepDetail.id === 'preprocessor'}
Preprocessor
{:else}
Anonymous step
{/if}
Expand All @@ -147,10 +156,12 @@
An identity step returns its inputs as outputs
</p>
{:else if stepDetail.value.type == 'rawscript'}
<div class="text-xs">
<h3 class="mb-2 font-semibold mt-2">Step Inputs</h3>
<InputTransformsViewer inputTransforms={stepDetail?.value?.input_transforms ?? {}} />
</div>
{#if stepDetail.id !== 'preprocessor'}
<div class="text-xs">
<h3 class="mb-2 font-semibold mt-2">Step Inputs</h3>
<InputTransformsViewer inputTransforms={stepDetail?.value?.input_transforms ?? {}} />
</div>
{/if}

<div>
<div class="mb-2 mt-4 flex justify-between items-center">
Expand Down Expand Up @@ -180,10 +191,12 @@
</div>
</div>
{:else if stepDetail.value.type == 'script'}
<div class="text-2xs">
<h3 class="mb-2 font-semibold mt-2">Step Inputs</h3>
<InputTransformsViewer inputTransforms={stepDetail?.value?.input_transforms ?? {}} />
</div>
{#if stepDetail.id !== 'preprocessor'}
<div class="text-2xs">
<h3 class="mb-2 font-semibold mt-2">Step Inputs</h3>
<InputTransformsViewer inputTransforms={stepDetail?.value?.input_transforms ?? {}} />
</div>
{/if}
{#if stepDetail.value.path.startsWith('hub/')}
<div class="flex flex-col grow">
<div class="mb-2 flex justify-between items-center">
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/lib/components/graph/graphBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,10 @@ export default function graphBuilder(
addEdge(id, 'Input', { type: 'empty' })
}

if (failureModule && !extra.flowModuleStates) {
addNode(failureModule, 0, 'module')
}

Object.keys(parents).forEach((key) => {
const node = nodes.find((n) => n.id === key)

Expand Down

0 comments on commit 8a277a0

Please sign in to comment.