{"record":{"id":"18ba28172f2ee40a","repo":"windmill-labs/windmill","slug":"no-flow-available-to-test-please-ensure-you-have","errorCode":null,"errorMessage":"No flow available to test. Please ensure you have a flow open in the editor.","messagePattern":"No flow available to test\\. Please ensure you have a flow open in the editor\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"frontend/src/lib/components/copilot/chat/flow/core.ts","lineNumber":412,"sourceCode":"\t\t\t\tallowResourcesFetch: true\n\t\t\t})\n\t\t\ttoolCallbacks.setToolStatus(toolId, {\n\t\t\t\tcontent: 'Retrieved instructions for code generation in ' + parsedArgs.language\n\t\t\t})\n\t\t\treturn langContext\n\t\t}\n\t},\n\t{\n\t\tdef: testRunFlowToolDef,\n\t\tfn: async function ({ args, workspace, helpers, toolCallbacks, toolId }) {\n\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...',","sourceCodeStart":394,"sourceCodeEnd":430,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/frontend/src/lib/components/copilot/chat/flow/core.ts#L394-L430","documentation":"The flow test tool throws when no flow (or flow.value) is present in the current editor context, meaning there is nothing to execute a test run against. It sets a tool status ('No flow available to test' / 'No flow found in current context') and raises so the model receives a failure result.","triggerScenarios":"Calling the test-flow tool when the copilot session is not attached to an open flow editor, the editor has no flow loaded yet, or flow.value is empty/undefined at call time.","commonSituations":"User invokes 'test the flow' from an AI session opened on a script or app rather than a flow; the flow editor is still loading; the session context was lost after a page reload.","solutions":["Open a flow in the editor (or attach the AI session to one) before calling the test tool.","Wait for the flow editor to finish loading and re-issue the tool call.","Create a new flow first if none exists, then run the test."],"exampleFix":"// before\nawait tools.testFlow({})\n// after\nconst flow = getCurrentEditorFlow()\nif (!flow?.value) {\n  return toolCallbacks.report('No flow open — open a flow in the editor first.')\n}\nawait tools.testFlow({})","handlingStrategy":"type-guard","validationCode":"const flow = getEditorContext()?.flow\nif (!flow?.value) {\n  toolCallbacks.setToolStatus(toolId, { content: 'No flow open', error: 'Open a flow first' })\n  return\n}","typeGuard":"function hasTestableFlow(ctx: EditorContext | undefined): ctx is EditorContext & { flow: { value: FlowValue } } {\n  return ctx?.flow?.value != null\n}","tryCatchPattern":"try {\n  await tools.testFlow(args)\n} catch (e) {\n  if (e.message.includes('No flow available to test')) {\n    return promptUserToOpenFlow()\n  }\n  throw e\n}","preventionTips":["Only enable/expose the test-flow tool when an open flow editor is attached to the session.","Verify editor context (flow and flow.value) is loaded before issuing test calls.","Re-attach session context after page reloads before running editor-dependent tools."],"tags":["flow","missing-context","tool-usage","editor"],"backgroundTag":"missing-editor-context","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"}