From 44762fff7f249600ff886f5a8d71f5f5eb20872d Mon Sep 17 00:00:00 2001 From: hugocasa Date: Tue, 26 May 2026 14:03:47 +0200 Subject: [PATCH] fix(cli): handle __flow suffix when deriving the flow's Windmill path --- cli/src/commands/flow/flow.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/cli/src/commands/flow/flow.ts b/cli/src/commands/flow/flow.ts index d778b3c4ee..4717711ae5 100644 --- a/cli/src/commands/flow/flow.ts +++ b/cli/src/commands/flow/flow.ts @@ -652,7 +652,7 @@ async function preview( // the anchor for relative-import resolution: inline scripts in this flow are // treated as living at "/", so "./util" resolves to // "/util" — matching the keys in temp_script_refs. - const flowWmPath = flowPath.substring(0, flowPath.indexOf(".flow")).replaceAll(SEP, "/"); + const flowWmPath = stripFlowSuffix(flowPath).replaceAll(SEP, "/"); if (opts.step) { await previewStep(opts.step, localFlow, flowWmPath, workspace, input, tempScriptRefs, opts.silent); @@ -797,6 +797,19 @@ async function previewStep( } } +// Strip the `.flow`/`__flow` directory suffix to recover the flow's logical +// Windmill path. Workspaces with nonDottedPaths use `__flow`; the default +// uses `.flow`. A previous version used `indexOf(".flow")` which returned -1 +// (and thus `substring(0, -1) === ""`) for `__flow` folders and for the +// `dirname("flow.yaml") === "."` fallback — producing an empty path that +// broke relative-import resolution downstream. +function stripFlowSuffix(flowPath: string): string { + const stripped = flowPath.endsWith(SEP) ? flowPath.slice(0, -SEP.length) : flowPath; + if (stripped.endsWith(".flow")) return stripped.slice(0, -".flow".length); + if (stripped.endsWith("__flow")) return stripped.slice(0, -"__flow".length); + return stripped; +} + function findStepInFlowValue(flowValue: any, stepId: string): any | undefined { if (!flowValue) return undefined; if (flowValue.failure_module?.id === stepId) return flowValue.failure_module;