{"record":{"id":"1ecde90aaa2c0cfc","repo":"windmill-labs/windmill","slug":"failed-to-start-test-run-testflow-returned-undef","errorCode":null,"errorMessage":"Failed to start test run - testFlow returned undefined","messagePattern":"Failed to start test run - testFlow returned undefined","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"frontend/src/lib/components/copilot/chat/flow/core.ts","lineNumber":423,"sourceCode":"\t\t\tconst { flow } = helpers.getFlowAndSelectedId()\n\n\t\t\tif (!flow || !flow.value) {\n\t\t\t\ttoolCallbacks.setToolStatus(toolId, {\n\t\t\t\t\tcontent: 'No flow available to test',\n\t\t\t\t\terror: 'No flow found in current context'\n\t\t\t\t})\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'No flow available to test. Please ensure you have a flow open in the editor.'\n\t\t\t\t)\n\t\t\t}\n\n\t\t\tconst parsedArgs = await buildTestRunArgs(args, this.def)\n\t\t\t// Use the UI test mechanism - this opens the preview panel\n\t\t\treturn executeTestRun({\n\t\t\t\tjobStarter: async () => {\n\t\t\t\t\tconst jobId = await helpers.testFlow(parsedArgs)\n\t\t\t\t\tif (!jobId) {\n\t\t\t\t\t\tthrow new Error('Failed to start test run - testFlow returned undefined')\n\t\t\t\t\t}\n\t\t\t\t\treturn jobId\n\t\t\t\t},\n\t\t\t\tworkspace,\n\t\t\t\ttoolCallbacks,\n\t\t\t\ttoolId,\n\t\t\t\tstartMessage: 'Starting flow test run...',\n\t\t\t\tcontextName: 'flow'\n\t\t\t})\n\t\t},\n\t\tsetSchema: async function (helpers: FlowAIChatHelpers) {\n\t\t\tawait buildSchemaForTool(this.def, async () => {\n\t\t\t\tconst flowInputsSchema = await helpers.getFlowInputsSchema()\n\t\t\t\treturn flowInputsSchema\n\t\t\t})\n\t\t},\n\t\trequiresConfirmation: true,\n\t\tconfirmationMessage: 'Run a test of the current flow',","sourceCodeStart":405,"sourceCodeEnd":441,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/frontend/src/lib/components/copilot/chat/flow/core.ts#L405-L441","documentation":"The flow 'test run' copilot tool wraps helpers.testFlow() and requires it to return a job ID for the started test run. When testFlow resolves to undefined (falsy), the tool throws this error instead of silently tracking a run it cannot monitor. It indicates the test-run starter failed to produce a job, typically before the backend actually queued anything.","triggerScenarios":"Calling the test_run_flow tool when helpers.testFlow(parsedArgs) resolves without a job ID — e.g. the underlying preview/test-run API returned no id, the flow value was stale or empty, or a UI-layer guard in testFlow short-circuits and returns undefined.","commonSituations":"Flow editor not fully hydrated when the AI triggers a test; backend request failed but testFlow swallowed the error and returned undefined; running against a stale/invalid flow draft that the test mechanism refuses to start.","solutions":["Ensure a valid flow is open and saved in the editor, then re-run the test tool.","Check the browser network/console logs for the failing test-run API call (it likely returned an error that testFlow swallowed).","Verify helpers.testFlow is wired to the current preview/run service and returns the created job's id on success.","Retry the test run; if it persists, restart the frontend dev server to clear stale editor state."],"exampleFix":"// before\nconst jobId = await helpers.testFlow(parsedArgs)\nif (!jobId) throw new Error('Failed to start test run - testFlow returned undefined')\n// after: make testFlow surface the real failure\nconst jobId = await helpers.testFlow(parsedArgs)\nif (!jobId) throw new Error('testFlow returned no job id — check the run/start API response')","handlingStrategy":"try-catch","validationCode":"const { flow } = helpers.getFlowAndSelectedId()\nif (!flow?.value) throw new Error('Open a valid flow before testing')\nconst parsedArgs = await buildTestRunArgs(args, def)","typeGuard":"function hasJobId(v: unknown): v is string { return typeof v === 'string' && v.length > 0 }","tryCatchPattern":"try {\n  const jobId = await helpers.testFlow(parsedArgs)\n  if (!jobId) throw new Error('testFlow returned no job id')\n} catch (e) {\n  showStatus(`Test run failed to start: ${e.message}; check the run API response and retry`)\n}","preventionTips":["Only invoke test runs from a fully loaded flow editor context","Make testFlow throw on API failure instead of returning undefined","Watch the network tab for the run/start request when tests won't start"],"tags":["frontend","copilot","test-run","flow-editor"],"backgroundTag":"test-run-start-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"}