{"record":{"id":"e812d3d2e7288e00","repo":"windmill-labs/windmill","slug":"only-scripts-can-be-used-as-a-input-schema","errorCode":null,"errorMessage":"only scripts can be used as a input schema","messagePattern":"only scripts can be used as a input schema","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"frontend/src/lib/components/flows/flowStore.svelte.ts","lineNumber":57,"sourceCode":"\t\tsendUserToast('Only scripts can be used as a input schema', true)\n\t\treturn\n\t}\n\tsendUserToast('No first step found', true)\n\treturn\n}\n\nexport async function getFirstStepSchema(flowState: FlowState, flow: OpenFlow) {\n\tconst firstModuleId = flow.value.modules[0]?.id\n\n\tif (!firstModuleId || !flowState[firstModuleId]) {\n\t\tthrow new Error('no first step found')\n\t}\n\n\tconst schema = $state.snapshot(flowState[firstModuleId].schema)\n\tconst v = flow.value.modules[0].value\n\n\tif (v.type !== 'rawscript' && v.type !== 'script') {\n\t\tthrow new Error('only scripts can be used as a input schema')\n\t}\n\n\tconst simplifiedModule = {\n\t\tid: flow.value.modules[0].id,\n\t\tsummary: flow.value.modules[0].summary,\n\t\tvalue: {\n\t\t\ttype: flow.value.modules[0].value.type,\n\t\t\t...('path' in flow.value.modules[0].value ? { path: flow.value.modules[0].value.path } : {}),\n\t\t\t...('language' in flow.value.modules[0].value\n\t\t\t\t? { language: flow.value.modules[0].value.language }\n\t\t\t\t: {})\n\t\t}\n\t}\n\n\treturn {\n\t\tschema,\n\t\tmod: simplifiedModule,\n\t\tconnectFirstNode: () => {","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/frontend/src/lib/components/flows/flowStore.svelte.ts#L39-L75","documentation":"After locating the first module, getFirstStepSchema only supports extracting an input schema from script-like modules. If the first module's value.type is neither 'rawscript' nor 'script' (e.g., a flow input, loop, branch, or approval step), there is no script input schema to derive, so it throws.","triggerScenarios":"Calling getFirstStepSchema on a flow whose first module is a subflow, flow-input, loop, while-loop, branch, or any non-script module type.","commonSituations":"Reusing a schema-derivation helper built for script-first flows on flows that start with a control/IO step; reordering flow steps so a non-script module becomes first; AI-generated or templated flows with a leading flow-input module.","solutions":["Verify the first module type before calling: only 'script' or 'rawscript' first steps are supported.","Point the schema extraction at the first script-type module rather than strictly modules[0].","Fall back to a manual/empty schema when the first step is not a script."],"exampleFix":"// before\nconst schema = await getFirstStepSchema(flowState, flow)\n// after\nconst first = flow.value.modules[0]?.value\nif (first?.type !== 'rawscript' && first?.type !== 'script') return null\nconst schema = await getFirstStepSchema(flowState, flow)","handlingStrategy":"type-guard","validationCode":"const v = flow.value.modules[0]?.value\nconst isScriptFirst = v?.type === 'rawscript' || v?.type === 'script'","typeGuard":"function firstModuleIsScript(flow: OpenFlow): boolean {\n  const v = flow.value.modules[0]?.value\n  return v?.type === 'rawscript' || v?.type === 'script'\n}","tryCatchPattern":"try {\n  const schema = await getFirstStepSchema(flowState, flow)\n} catch (e) {\n  if (e.message.includes('input schema')) return buildEmptySchema()\n  throw e\n}","preventionTips":["Locate the first script-type module instead of assuming modules[0].","Re-derive schema targets after step reordering.","Show schema UI only for script-first flows."],"tags":["svelte","flow-editor","unsupported-module-type"],"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"}