{"record":{"id":"331bd578403221d5","repo":"windmill-labs/windmill","slug":"backend-runnable-target-key-not-found","errorCode":null,"errorMessage":"Backend runnable '${target.key}' not found.","messagePattern":"Backend runnable '(.+?)' not found\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"frontend/src/lib/components/copilot/chat/app/core.ts","lineNumber":621,"sourceCode":"\t\t\tlet currentContent = ''\n\t\t\tlet backendRunnable: BackendRunnable | undefined\n\n\t\t\tif (target.type === 'frontend') {\n\t\t\t\tif (target.path === '/wmill.d.ts') {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\"'/wmill.d.ts' is generated automatically. Edit backend runnables instead.\"\n\t\t\t\t\t)\n\t\t\t\t}\n\n\t\t\t\tconst frontendContent = helpers.getFrontendFile(target.path)\n\t\t\t\tif (frontendContent === undefined) {\n\t\t\t\t\tthrow new Error(`Frontend file '${target.path}' not found.`)\n\t\t\t\t}\n\t\t\t\tcurrentContent = frontendContent\n\t\t\t} else {\n\t\t\t\tbackendRunnable = helpers.getBackendRunnable(target.key)\n\t\t\t\tif (!backendRunnable) {\n\t\t\t\t\tthrow new Error(`Backend runnable '${target.key}' not found.`)\n\t\t\t\t}\n\t\t\t\tif (backendRunnable.type !== 'inline' || !backendRunnable.inlineScript) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`'${target.path}' points to backend runnable '${target.key}', but only inline runnables can be patched as files.`\n\t\t\t\t\t)\n\t\t\t\t}\n\n\t\t\t\tconst expectedExtension = getBackendInlineScriptExtension(backendRunnable)\n\t\t\t\tif (target.extension !== expectedExtension) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`'${target.path}' does not match runnable '${target.key}' language. Use backend/${target.key}/main.${expectedExtension}.`\n\t\t\t\t\t)\n\t\t\t\t}\n\n\t\t\t\tcurrentContent = backendRunnable.inlineScript.content ?? ''\n\t\t\t}\n\n\t\t\tconst updatedContent = findAndReplace(","sourceCodeStart":603,"sourceCodeEnd":639,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/frontend/src/lib/components/copilot/chat/app/core.ts#L603-L639","documentation":"When the patch path targets a backend runnable (backend/<key>/main.ts|py), applyPatch looks the runnable up by key via helpers.getBackendRunnable. This error is thrown when no runnable with that key exists in the app's frontend definition. It catches references to deleted, renamed, or never-existing backend runnables.","triggerScenarios":"Patching 'backend/my_step/main.ts' when the app's runnables map has no 'my_step' key — the runnable was renamed, removed by a previous patch, or the model invented the key.","commonSituations":"Model guessing runnable names instead of listing them; earlier diff removed the runnable; key casing/spelling mismatch; editing a flow-generated app where steps use different ids.","solutions":["List the app's backend runnables first and patch an existing key","Re-create the runnable (via the add-runnable tool) before patching its file","Verify the key segment between backend/ and /main — it must exactly equal the runnable id in the app definition"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const runnable = helpers.getBackendRunnable(key)\nif (!runnable) throw new Error(`No backend runnable named ${key}`)","typeGuard":"function backendRunnableExists(key: string, helpers: AppHelpers): boolean {\n  return helpers.getBackendRunnable(key) !== undefined\n}","tryCatchPattern":"try {\n  await patchTool({ path: `backend/${key}/main.ts`, ... })\n} catch (e) {\n  if (e instanceof Error && e.message.startsWith('Backend runnable')) {\n    toolCallbacks.report(`Runnable '${key}' does not exist; list runnables first`)\n    return\n  }\n  throw e\n}","preventionTips":["Enumerate the app's runnables before constructing backend/<key>/main.* paths","Never guess runnable keys — take them from the app definition or a prior listing","Account for renames/deletions from earlier steps in the same session"],"tags":["copilot","app-editor","file-not-found"],"backgroundTag":"file-not-found","analyzedSha":"e474e8803ce2ff5c2df09a58dab51d45f5c922ca","analyzedAt":"2026-09-03T12:38:19.024Z","contentChangedAt":"2026-09-03T12:38:19.024Z","schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}