{"record":{"id":"e446025a88c8ed8b","repo":"windmill-labs/windmill","slug":"failed-to-create-flow-remotepath-e-body-e","errorCode":null,"errorMessage":"Failed to create flow ${remotePath}: ${e.body ?? e.message}","messagePattern":"Failed to create flow (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/src/commands/flow/flow.ts","lineNumber":300,"sourceCode":"        },\n      });\n    }\n  } else {\n    log.info(colors.bold.yellow(\"Creating new flow...\"));\n    try {\n      await wmill.createFlow({\n        workspace: workspace,\n        requestBody: {\n          path: remotePath.replaceAll(SEP, \"/\"),\n          deployment_message: message,\n          ...localFlowBody,\n          ...preserveFields,\n          // Preserve any user draft at this path (see backend skip_draft_deletion).\n          skip_draft_deletion: true,\n        },\n      });\n    } catch (e) {\n      throw new Error(\n        //@ts-ignore\n        `Failed to create flow ${remotePath}: ${e.body ?? e.message}`\n      );\n    }\n  }\n\n  // Independent of whether the flow body changed, sync extra_perms via /acls/*.\n  // Self-contained log line + non-fatal failures.\n  //\n  // No refetch is needed: extra_perms is item-specific and additive on top of\n  // folder perms — folder perms are never merged onto item.extra_perms. And\n  // since the request body sent to update_flow / create_flow doesn't carry\n  // extra_perms, the value we read in the initial getFlowByPath above is\n  // also the post-write value (a no-op deploy can't drift it).\n  await applyExtraPermsDiff(\n    workspace,\n    \"flow\",\n    remotePath.replaceAll(SEP, \"/\"),","sourceCodeStart":282,"sourceCodeEnd":318,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/cli/src/commands/flow/flow.ts#L282-L318","documentation":"This error wraps any failure from the Windmill API when the CLI attempts to create a flow via `wmill flow push`. The thrown message interpolates the target remote path and the API error body (or message if the SDK didn't parse a body), so it is a generic wrapper around upstream create-flow failures such as validation errors, conflicts, or auth problems.","triggerScenarios":"Running `wmill flow push` (or pushObj) where the POST/UPDATE to create the flow fails: invalid flow value YAML/JSON, a path conflict with different resource kind, missing workspace permission, or malformed `skip_draft_deletion`/preserveFields payload.","commonSituations":"Deploying flows from CI where the token lacks write access; pushing a flow.yaml edited by hand with invalid module structure; pushing to a workspace where the path is taken by a script/app; API version drift between CLI and server.","solutions":["Inspect the interpolated error body — it contains the server's validation message; fix the flow definition accordingly","Verify the token/workspace has write permissions for flows (`wmill workspace` shows the active one)","Validate the flow.yaml locally with `wmill flow validate` if available, or push once with the frontend UI to surface the field error","Check CLI/server version compatibility and upgrade the CLI"],"exampleFix":"// before\nwmill flow push f/policies/audit --skip-partial-validation\n// after\nwmill flow validate f/policies/audit && wmill flow push f/policies/audit","handlingStrategy":"try-catch","validationCode":"const exists = await wmill.getFlowByPath({ workspace, path: remotePath }).catch(() => null);\nif (exists) console.warn(`Flow ${remotePath} already exists; it will be updated`);\nif (!flowValue?.value?.modules?.length) throw new Error('flow value has no modules');","typeGuard":"function isApiError(e: unknown): e is { body?: { message?: string }; message: string } {\n  return typeof e === 'object' && e !== null && 'message' in e;\n}","tryCatchPattern":"try {\n  await wmill.createFlow({ workspace, path: remotePath, requestBody: flowValue });\n} catch (e) {\n  const detail = (e as any)?.body?.message ?? (e as any)?.message ?? String(e);\n  console.error(`Push of ${remotePath} rejected by server: ${detail}`);\n  process.exitCode = 1;\n}","preventionTips":["Run flow validation/lint locally before pushing in CI","Use a deploy token with scoped write permissions on flows","Pin CLI version to match the server version","Push from the repo root so relative paths in the flow resolve"],"tags":["cli","flow-push","api-error"],"backgroundTag":"flow-push-failed","analyzedSha":"e474e8803ce2ff5c2df09a58dab51d45f5c922ca","analyzedAt":"2026-09-03T12:38:19.024Z","contentChangedAt":"2026-09-03T12:38:19.024Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}