{"record":{"id":"c462f9517bb9dac2","repo":"windmill-labs/windmill","slug":"no-first-step-found","errorCode":null,"errorMessage":"no first step found","messagePattern":"no first step found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"frontend/src/lib/components/flows/flowStore.svelte.ts","lineNumber":50,"sourceCode":"\t\t\t\tv.input_transforms[key] = {\n\t\t\t\t\ttype: 'javascript',\n\t\t\t\t\texpr: `flow_input.${key}`\n\t\t\t\t}\n\t\t\t})\n\t\t\treturn\n\t\t}\n\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: {})","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/frontend/src/lib/components/flows/flowStore.svelte.ts#L32-L68","documentation":"getFirstStepSchema reads the input schema from the flow's first module. It throws when the flow has no modules at all (flow.value.modules[0] is undefined) or when the flowState map has no entry for the first module's id — meaning the first step's state was never initialized.","triggerScenarios":"Calling getFirstStepSchema with an empty flow (modules array empty) or with a FlowState object missing the key for flow.value.modules[0].id (e.g., state built from a different or partially-loaded flow).","commonSituations":"Previewing input schema for a brand-new empty flow; flow state and flow definition out of sync after a partial load or race during flow initialization; passing a flowState snapshot from another flow version.","solutions":["Ensure the flow has at least one module before calling (flow.value.modules.length > 0).","Initialize flowState entries for every module id before invoking; await flow state initialization before schema reads.","Guard the call site: skip schema extraction when the first module is missing from state."],"exampleFix":"// before\nconst schema = await getFirstStepSchema(flowState, flow)\n// after\nconst firstId = flow.value.modules[0]?.id\nif (!firstId || !flowState[firstId]) return null\nconst schema = await getFirstStepSchema(flowState, flow)","handlingStrategy":"type-guard","validationCode":"const firstModuleId = flow.value.modules[0]?.id\nconst ready = Boolean(firstModuleId && flowState[firstModuleId])","typeGuard":"function hasFirstStepState(fs: FlowState, flow: OpenFlow): fs is FlowState & Record<string, { schema: unknown }> {\n  const id = flow.value.modules[0]?.id\n  return !!id && !!fs[id]\n}","tryCatchPattern":"try {\n  const schema = await getFirstStepSchema(flowState, flow)\n} catch (e) {\n  if (e.message === 'no first step found') return null\n  throw e\n}","preventionTips":["Always await flow state initialization before schema reads.","Never pass a FlowState from a different flow instance/version.","Check modules.length before accessing modules[0]."],"tags":["svelte","flow-editor","missing-state"],"backgroundTag":"missing-state-key","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"}