{"record":{"id":"e90f9496f5e026ca","repo":"windmill-labs/windmill","slug":"could-not-find-the-selected-id-in-the-flow-e90f94","errorCode":null,"errorMessage":"Could not find the selected id in the flow","messagePattern":"Could not find the selected id in the flow","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"frontend/src/lib/components/copilot/StepInputGen.svelte","lineNumber":77,"sourceCode":"\t\t\t$schema: 'https://json-schema.org/draft/2020-12/schema',\n\t\t\tproperties,\n\t\t\trequired,\n\t\t\ttype: 'object'\n\t\t}\n\t}\n\n\tasync function generateStepInput() {\n\t\tif (generatedContent.length > 0 || loading) {\n\t\t\treturn\n\t\t}\n\t\tlogStepInputFill('single')\n\t\tabortController = new AbortController()\n\t\tloading = true\n\t\tconst flow: Flow = JSON.parse(JSON.stringify(flowStore.val))\n\t\tconst idOrders = dfs(flow.value.modules, (x) => x.id)\n\t\tconst upToIndex = idOrders.indexOf(selectionManager.getSelectedId())\n\t\tif (upToIndex === -1) {\n\t\t\tthrow new Error('Could not find the selected id in the flow')\n\t\t}\n\n\t\tconst flowDetails =\n\t\t\t'Take into account the following information for never tested results:\\n<flowDetails>\\n' +\n\t\t\tyamlStringifyExceptKeys(sliceModules(flow.value.modules, upToIndex, idOrders), ['lock']) +\n\t\t\t'</flowDetails>'\n\t\ttry {\n\t\t\tconst availableData = {\n\t\t\t\tresults: pickableProperties?.priorIds,\n\t\t\t\tflow_input: pickableProperties?.flow_input\n\t\t\t}\n\t\t\tconst isInsideLoop = availableData.flow_input && 'iter' in availableData.flow_input\n\t\t\tconst user = `I'm building a workflow which is a DAG of script steps.\nThe current step is ${selectionManager.getSelectedId()}, you can find the details for the step and previous ones below:\n${flowDetails}\nDetermine for the input \"${argName}\", what to pass either from the previous results or the flow inputs. \nAll possibles inputs either start with results. or flow_input. and are followed by the key of the input.\n${","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/frontend/src/lib/components/copilot/StepInputGen.svelte#L59-L95","documentation":"StepInputGen.svelte's generateStepInput() validates the selection the same way before slicing flow context for the AI; a selected id missing from the DFS-ordered module ids throws 'Could not find the selected id in the flow'.","triggerScenarios":"Invoking step-input AI generation with selectionManager.getSelectedId() not present in flow.value.modules (stale/foreign selection).","commonSituations":"Clicking generate from a panel whose selection was cleared or points to a different view; flow replaced (e.g. after save/reload) invalidating ids; selecting an iterator's internal id.","solutions":["Click directly on the target step in the flow canvas, then run generation","Reload the flow in the editor to resync ids, then retry","Ensure the step exists at the top level (or that the DFS includes loop children) before generating"],"exampleFix":"null","handlingStrategy":"validation","validationCode":"const idOrders = dfs(flowStore.val.value.modules, (x) => x.id)\nif (!idOrders.includes(selectionManager.getSelectedId())) {\n  console.warn('Selection not found in flow; re-select a step')\n  return\n}","typeGuard":"function selectionInFlow(flow: Flow, selectedId: string | undefined): boolean {\n  return !!selectedId && dfs(flow.value.modules, (x) => x.id).includes(selectedId)\n}","tryCatchPattern":"try {\n  await generateStepInput()\n} catch (e) {\n  if (e.message === 'Could not find the selected id in the flow') {\n    console.warn('Re-select a flow step and retry step-input generation')\n  } else throw e\n}","preventionTips":["Verify selection after every flow reload/save before generating","Do not trigger generation while a different tab/panel holds the selection","Keep ids stable by avoiding parallel edits to the same flow"],"tags":["copilot","flow-editor","stale-selection"],"backgroundTag":"selected-node-not-in-flow","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"}