{"record":{"id":"51f338666178f642","repo":"windmill-labs/windmill","slug":"can-t-create-script-from-non-inline-script","errorCode":null,"errorMessage":"Can't create script from non-inline script","messagePattern":"Can't create script from non-inline script","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"frontend/src/lib/components/flows/flowStateUtils.svelte.ts","lineNumber":288,"sourceCode":"\treturn {\n\t\tid: nextId(flowState, fullFlow),\n\t\tvalue: { type: 'identity', flow }\n\t}\n}\n\nexport async function createScriptFromInlineScript(\n\tflowModule: FlowModule,\n\tsuffix: string,\n\tschema: Schema | undefined,\n\tflowPath: string,\n\t// The session's acting workspace when the flow editor runs in an AI session;\n\t// falls back to the navigation workspace outside a session.\n\tworkspace?: string\n): Promise<[FlowModule & { value: PathScript }, FlowModuleState]> {\n\tconst user = get(userStore)\n\n\tif (flowModule.value.type != 'rawscript') {\n\t\tthrow new Error(\"Can't create script from non-inline script\")\n\t}\n\n\tconst originalScriptPath = flowModule.value.path\n\tconst wasForked = Boolean(originalScriptPath)\n\n\tif (wasForked && originalScriptPath) {\n\t\tconst [_first, _second, ...others] = originalScriptPath.split('/')\n\t\tsuffix = others.join('/')\n\t}\n\n\tconst path = `${flowPath}/${suffix}`\n\tconst forkedDescription = wasForked ? `as a fork of ${originalScriptPath}` : ''\n\tconst description = `This script was edited in place of flow ${flowPath} ${forkedDescription} by ${user?.username}.`\n\n\tconst availablePath = await findNextAvailablePath(path, workspace)\n\n\tconst hash = await ScriptService.createScript({\n\t\tworkspace: workspace ?? get(workspaceStore)!,","sourceCodeStart":270,"sourceCodeEnd":306,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/frontend/src/lib/components/flows/flowStateUtils.svelte.ts#L270-L306","documentation":"createScriptFromInlineScript forks a flow module's inline (rawscript) code into a standalone script. It only works when flowModule.value.type is 'rawscript'; if the module references a pre-existing script (type 'script') or another resource, there is no inline code to fork, so the function throws immediately after reading the user store.","triggerScenarios":"Calling createScriptFromInlineScript(flowModule, ...) with a module whose value.type is 'script' (path-referenced script), 'hubscript', or any non-'rawscript' type.","commonSituations":"User clicks 'fork/edit as standalone script' on a flow step that was added from the hub or already references a saved script path; programmatic flow manipulation that iterates all modules without filtering by type; stale UI state where a module was converted from inline to path-referenced.","solutions":["Check flowModule.value.type === 'rawscript' before calling; route 'script' modules to a different edit flow (navigate to the script itself or fork via the script editor).","If you need to fork a path-referenced script, fetch the script content by its path and create a rawscript module first, then call this function.","Filter flow.value.modules to rawscript-only entries when batch-forking steps."],"exampleFix":"// before\nconst [newModule, state] = await createScriptFromInlineScript(flowModule)\n// after\nif (flowModule.value.type !== 'rawscript') {\n  goto(`/scripts/get/${flowModule.value.path}`)\n} else {\n  const [newModule, state] = await createScriptFromInlineScript(flowModule)\n}","handlingStrategy":"validation","validationCode":"function canFork(flowModule: FlowModule): boolean {\n  return flowModule.value.type === 'rawscript'\n}","typeGuard":"function isRawscriptModule(m: FlowModule): m is FlowModule & { value: { type: 'rawscript' } } {\n  return m.value.type === 'rawscript'\n}","tryCatchPattern":"try {\n  await createScriptFromInlineScript(flowModule)\n} catch (e) {\n  if (e.message.includes(\"non-inline script\")) {\n    toast.error('This step references a saved script; open the script to edit it.')\n  } else throw e\n}","preventionTips":["Only offer the fork action in the UI for inline (rawscript) steps.","Filter modules by type before batch operations.","Handle 'script' steps by navigating to the script editor instead."],"tags":["svelte","flow-editor","invalid-argument"],"backgroundTag":"unsupported-operation","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"}