From a0273f8152b3ece7b7eea1c8e00df3bb3b790ab0 Mon Sep 17 00:00:00 2001 From: Diego Imbert Date: Tue, 2 Jun 2026 14:46:37 +0200 Subject: [PATCH] fix: tolerate missing latest-version on draft-only flow reload --- .../flows/edit/[...path]/+page.svelte | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/frontend/src/routes/(root)/(logged)/flows/edit/[...path]/+page.svelte b/frontend/src/routes/(root)/(logged)/flows/edit/[...path]/+page.svelte index 5b38eb56ea..28dbd2e3f3 100644 --- a/frontend/src/routes/(root)/(logged)/flows/edit/[...path]/+page.svelte +++ b/frontend/src/routes/(root)/(logged)/flows/edit/[...path]/+page.svelte @@ -190,13 +190,24 @@ return } // Currently there is no way to get version of flow with flow. - // So we have to request it here - const v = ( - await FlowService.getFlowLatestVersion({ - workspace: $workspaceStore!, - path: page.params.path ?? '' - }) - ).id + // So we have to request it here. + // + // Tolerate a missing version: when the path is draft-only (no + // deployed flow at this path), `getFlowLatestVersion` returns no + // row and `.id` would throw on `null`. The `getFlowByPath` call + // below still returns the draft via the `get_draft` overlay, so + // the editor can mount with `version = undefined`. + let v: number | undefined + try { + v = ( + await FlowService.getFlowLatestVersion({ + workspace: $workspaceStore!, + path: page.params.path ?? '' + }) + )?.id + } catch { + v = undefined + } if (tok !== loadFlowToken) return version = v