{"record":{"id":"e823080751a08a17","repo":"windmill-labs/windmill","slug":"wmill-d-ts-is-generated-automatically-edit-bac","errorCode":null,"errorMessage":"'/wmill.d.ts' is generated automatically. Edit backend runnables instead.","messagePattern":"'/wmill\\.d\\.ts' is generated automatically\\. Edit backend runnables instead\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"frontend/src/lib/components/copilot/chat/app/core.ts","lineNumber":608,"sourceCode":"\t\tstreamArguments: true,\n\t\tshowDetails: true,\n\t\tshowFade: true\n\t},\n\t{\n\t\tdef: getPatchFileToolDef(),\n\t\tstreamArguments: true,\n\t\tshowDetails: true,\n\t\tshowFade: true,\n\t\tfn: async ({ args, helpers, toolId, toolCallbacks }) => {\n\t\t\tconst parsedArgs = getPatchFileSchema().parse(args)\n\t\t\tconst { old_string: oldString, new_string: newString, replace_all: replaceAll } = parsedArgs\n\t\t\tconst target = resolveAppPatchTarget(parsedArgs.path)\n\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)","sourceCodeStart":590,"sourceCodeEnd":626,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/frontend/src/lib/components/copilot/chat/app/core.ts#L590-L626","documentation":"In the app-edit copilot's applyPatch tool, paths under /wmill.d.ts are rejected because that file is generated automatically from backend runnables. The error tells the model/developer to edit backend runnables (backend/<key>/main.ts|py) instead; the .d.ts is regenerated from them, so hand-edits would be overwritten.","triggerScenarios":"The AI model issues an app patch with path '/wmill.d.ts' (or '/wmill.d.ts' trimmed) and resolveAppPatchTarget classifies it as a frontend file; happens when the model tries to fix type errors by editing the generated typings directly.","commonSituations":"Model confusion after seeing wmill.d.ts type errors in diagnostics; prompts that mention the generated file; a model attempting to add custom type declarations for frontend use.","solutions":["Patch the backend runnable source instead: backend/<key>/main.ts or backend/<key>/main.py — the .d.ts regenerates from it","If extra frontend types are needed, put them in a normal frontend file (e.g. /types.ts) rather than wmill.d.ts","Adjust the model prompt/system instructions to state that /wmill.d.ts is read-only generated output"],"exampleFix":"// before\npatchFile('/wmill.d.ts', '...custom typings...')\n// after\npatchFile('backend/runnable_key/main.ts', '...fix source so typings regenerate...')","handlingStrategy":"validation","validationCode":"if (path.replace(/^\\//, '') === 'wmill.d.ts') {\n  throw new Error('wmill.d.ts is generated; edit backend runnables instead')\n}","typeGuard":"function isGeneratedTypings(path: string): boolean {\n  return path.replace(/^\\//, '') === 'wmill.d.ts'\n}","tryCatchPattern":"try {\n  await patchTool({ path, content })\n} catch (e) {\n  if (e instanceof Error && e.message.includes('wmill.d.ts')) {\n    toolCallbacks.report('wmill.d.ts is generated; patch the owning backend runnable instead')\n    return\n  }\n  throw e\n}","preventionTips":["Tell the model in system instructions that wmill.d.ts is read-only generated output","Filter generated paths out of file listings presented to the model","Map type-error fixes to the backend runnable that produces the typings"],"tags":["copilot","app-editor","generated-file"],"backgroundTag":"generated-file-overwrite","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"}