{"record":{"id":"20ff34cef290660e","repo":"windmill-labs/windmill","slug":"runnable-target-key-is-not-inline-use-read-w","errorCode":null,"errorMessage":"Runnable \"${target.key}\" is not inline. Use read_workspace_item on the referenced ${runnable.runType ?? 'item'} instead.","messagePattern":"Runnable \"(.+?)\" is not inline\\. Use read_workspace_item on the referenced (.+?) instead\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"frontend/src/lib/components/copilot/chat/global/core.ts","lineNumber":1775,"sourceCode":"\treturn runnable?.inlineScript?.language === 'python3' ? 'py' : 'ts'\n}\n\n/**\n * Resolve a backend file target to its inline script body, validating that the\n * runnable exists, is inline, and matches the requested file extension. Throws\n * with a clear message otherwise.\n */\nfunction getInlineRunnableContent(\n\tvalue: AppDraftValue,\n\ttarget: { kind: 'backend'; filePath: string; key: string; extension: 'ts' | 'py' },\n\tappPath: string\n): { content: string; runnable: PersistedRunnable } {\n\tconst runnable = value.runnables[target.key] as PersistedRunnable | undefined\n\tif (!runnable) {\n\t\tthrow new Error(`Backend runnable \"${target.key}\" not found in app \"${appPath}\".`)\n\t}\n\tif (runnable.type !== 'inline' && runnable.type !== 'runnableByName') {\n\t\tthrow new Error(\n\t\t\t`Runnable \"${target.key}\" is not inline. Use read_workspace_item on the referenced ${runnable.runType ?? 'item'} instead.`\n\t\t)\n\t}\n\tconst expected = getInlineScriptExtension(runnable)\n\tif (target.extension !== expected) {\n\t\tthrow new Error(\n\t\t\t`Runnable \"${target.key}\" language is ${expected}. Use backend/${target.key}/main.${expected}.`\n\t\t)\n\t}\n\treturn { content: runnable.inlineScript?.content ?? '', runnable }\n}\n\nasync function loadAppValueForRead(path: string, workspace: string): Promise<AppDraftValue> {\n\tconst draft = await getGlobalDraft(workspace, 'app', path)\n\tif (draft && draft.value && typeof draft.value === 'object' && 'files' in draft.value) {\n\t\treturn draft.value as AppDraftValue\n\t}\n","sourceCodeStart":1757,"sourceCodeEnd":1793,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/frontend/src/lib/components/copilot/chat/global/core.ts#L1757-L1793","documentation":"The AI chat backend tool resolver only accepts runnables stored inline in the app draft (type 'inline' or 'runnableByName'). When a runnable references a shared workspace item (script, flow, etc.), editing it in place is not allowed; the model must fetch and read it via the read_workspace_item tool. This guard prevents accidentally overwriting shared workspace resources through the app draft.","triggerScenarios":"A tool call targeting a backend runnable whose entry in value.runnables[key] has a type other than 'inline' or 'runnableByName' (e.g. a referenced workspace script/flow), while trying to read/write its content via the backend file tools.","commonSituations":"The app was configured to reference a shared script or flow by path rather than embedding inline code; the model attempts to edit the referenced item's content as if it were inline.","solutions":["Inspect value.runnables[target.key] to see the referenced runType and path","Call read_workspace_item with the referenced item path to fetch its content","Edit the referenced workspace item through its own workspace tool, not through the app draft","Or change the app so the runnable is inline (type 'inline') if in-app editing is intended"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if (runnable.type !== 'inline' && runnable.type !== 'runnableByName') {\n  // route to read_workspace_item with runnable.runType and its path instead\n  return readWorkspaceItem(runnable.path)\n}","typeGuard":"function isInlineRunnable(r) { return r && (r.type === 'inline' || r.type === 'runnableByName'); }","tryCatchPattern":"try { const { content } = resolveBackendFile(target, appPath) } catch (e) { if (String(e.message).includes('not inline')) return readWorkspaceItem(...); throw e }","preventionTips":["Check runnable.type before targeting backend files","Use read_workspace_item for referenced scripts/flows","Prefer inline runnables when in-app editing is intended"],"tags":["ai-copilot","workspace-item","app-runnable"],"backgroundTag":"non-inline-runnable-reference","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"}