From 4f1d6360056f2edbb687f5ae79004168c96ea4aa Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Mon, 20 Jul 2026 13:10:26 +0200 Subject: [PATCH] fall back to createFlow when the update target does not exist (#10206) FlowBuilder's deploy branches solely on the `newFlow` prop. When an embedder mounts the builder with `newFlow` false for a flow that was never deployed, Deploy issues `PUT /flows/update/{initialPath}` and the backend answers `Flow not found at name `, so the first deploy can never land. Confirm against `GET /flows/exists/{path}` before taking the update branch, and create instead when nothing is deployed there. The create path and the full-page editor (where `newFlow` is derived from `no_deployed`) are unchanged. Fixes WIN-2206 Co-authored-by: Claude Opus 4.8 (1M context) --- frontend/src/lib/components/FlowBuilder.svelte | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/frontend/src/lib/components/FlowBuilder.svelte b/frontend/src/lib/components/FlowBuilder.svelte index 12423e19b2..32767864a6 100644 --- a/frontend/src/lib/components/FlowBuilder.svelte +++ b/frontend/src/lib/components/FlowBuilder.svelte @@ -413,7 +413,22 @@ // loadingSave = false // del // return - if (newFlow) { + // `newFlow` comes from the embedder, and updating a path that has no + // deployed flow 404s. Confirm with the server before taking the update + // branch so a first deploy still lands. + let isNewFlow = newFlow + if (!isNewFlow) { + try { + isNewFlow = + initialPath === '' || + !(await FlowService.existsFlowByPath({ workspace: opWorkspace!, path: initialPath })) + } catch (err) { + // Unreachable check: keep the caller's intent rather than failing the deploy. + console.error('Could not check flow existence', err) + } + } + + if (isNewFlow) { await FlowService.createFlow({ workspace: opWorkspace!, requestBody: {