windmill-labs/windmill · error
No script code available to test. Please ensure you have a s
Error message
No script code available to test. Please ensure you have a script open in the editor.
What it means
The test-run tool for scripts requires script options (code/path) to be present in the current chat context before it can build and execute a test run. When none are found it throws this message telling the user to open a script in the editor first. It also sets a tool status so the model knows no script was available.
Source
Thrown at frontend/src/lib/components/copilot/chat/script/core.ts:900
content: 'Failed to apply code changes',
error: errorMessage
})
throw new Error(`Failed to apply code changes: ${errorMessage}`)
}
}
}
export const testRunScriptTool: Tool<ScriptChatHelpers> = {
def: TEST_RUN_SCRIPT_TOOL,
fn: async function ({ args, workspace, helpers, toolCallbacks, toolId }) {
const scriptOptions = helpers.getScriptOptions()
if (!scriptOptions) {
toolCallbacks.setToolStatus(toolId, {
content: 'No script available to test',
error: 'No script found in current context'
})
throw new Error(
'No script code available to test. Please ensure you have a script open in the editor.'
)
}
const parsedArgs = await buildTestRunArgs(args, this.def)
return executeTestRun({
jobStarter: () =>
JobService.runScriptPreview({
workspace: workspace,
requestBody: {
path: scriptOptions.path,
content: scriptOptions.code,
args: parsedArgs,
language: scriptOptions.lang as ScriptLang
}
}),
workspace,View on GitHub (pinned to e474e8803c)
Solutions
- Open a script in the editor so the chat context has script code/path, then ask the model to test again.
- Start the copilot chat from within a script editor rather than a global/dashboard page.
- If a script should be in context, check that the editor tab is focused/saved so helpers can resolve its path and hash.
- For flow-related testing, switch the chat to flow mode where the test-run tool can target flow steps instead.
Example fix
// before
// chat opened with no editor content; tool throws
// after
const code = editor.getValue()
if (code.trim()) {
await chat.testRun({ path: scriptPath })
} else {
openScript('scripts/foo.py')
} Defensive patterns
Strategy: validation
Validate before calling
const scriptOptions = getScriptChatOptions()
if (!scriptOptions?.path || !scriptOptions?.code?.trim()) {
// do not call the tool; open a script first
return 'Open a script in the editor before asking the assistant to test it.'
} Type guard
function hasScriptContext(opts: unknown): opts is { path: string; code: string } {
return !!opts && typeof opts === 'object' &&
typeof (opts as any).path === 'string' && (opts as any).path.length > 0 &&
typeof (opts as any).code === 'string' && (opts as any).code.trim().length > 0
} Try / catch
try {
await testRunScriptTool.fn({ args, workspace, helpers, toolCallbacks, toolId })
} catch (e) {
if (e instanceof Error && e.message.includes('No script code available to test')) {
// prompt user to open a script, then retry
}
} Prevention
- Open the target script in the editor before starting the copilot chat.
- Verify the chat header shows the script path before asking for test runs.
- Don't close the editor tab mid-conversation.
- For non-script artifacts, switch the chat to the matching mode (flow/app).
When it happens
Trigger: testRunScriptTool.fn was invoked while scriptOptions was null/undefined — i.e. the chat context contains no script (no open editor tab, or the helpers could not resolve a script path/hash for the current context).
Common situations: User opened the AI chat from a contextless view (e.g. an empty editor tab or a non-script page) and asked the model to 'test it'; the editor tab was closed mid-chat; the chat was started before any script was loaded so helpers had nothing to bind to.
Related errors
- Failed to start test run - testFlow returned undefined
- No flow available to test step from. Please ensure you have
- Test execution timed out after 60 seconds
- Failed to execute test run: ${errorMessage}
- AI response was empty
AI-assisted analysis of windmill-labs/windmill@e474e8803c (2026-09-03).
Data as JSON: /api/errors/c86670cb497050bf.
Report an issue: GitHub.