{"record":{"id":"f2579d8af124850a","repo":"windmill-labs/windmill","slug":"filepath-is-generated-automatically-from-back","errorCode":null,"errorMessage":"\"${filePath}\" is generated automatically from backend runnables and cannot be modified directly.","messagePattern":"\"(.+?)\" is generated automatically from backend runnables and cannot be modified directly\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"frontend/src/lib/components/copilot/chat/global/core.ts","lineNumber":1729,"sourceCode":"\t\t...(value.data && { data: value.data })\n\t}\n}\n\nfunction appToItem(app: ListableApp | AppWithLastVersion, includeValue: boolean): WorkspaceItem {\n\treturn {\n\t\ttype: 'app',\n\t\tpath: app.path,\n\t\tsummary: app.summary,\n\t\tvalue: includeValue ? ((app as AppWithLastVersion).value as AppDraftValue) : undefined,\n\t\tisDraft: false\n\t}\n}\n\nconst GENERATED_APP_FILE_PATHS = new Set(['/wmill.d.ts'])\n\nfunction assertNotGeneratedAppFile(filePath: string): void {\n\tif (GENERATED_APP_FILE_PATHS.has(filePath)) {\n\t\tthrow new Error(\n\t\t\t`\"${filePath}\" is generated automatically from backend runnables and cannot be modified directly.`\n\t\t)\n\t}\n}\n\ntype AppFileTarget =\n\t| { kind: 'frontend'; filePath: string }\n\t| { kind: 'backend'; filePath: string; key: string; extension: 'ts' | 'py' }\n\nfunction resolveAppFileTarget(rawPath: string): AppFileTarget {\n\tconst trimmed = rawPath.trim()\n\tconst backendMatch = trimmed.match(/^backend\\/([^/]+)\\/main\\.(ts|py)$/)\n\tif (backendMatch) {\n\t\treturn {\n\t\t\tkind: 'backend',\n\t\t\tfilePath: trimmed,\n\t\t\tkey: backendMatch[1],\n\t\t\textension: backendMatch[2] as 'ts' | 'py'","sourceCodeStart":1711,"sourceCodeEnd":1747,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/frontend/src/lib/components/copilot/chat/global/core.ts#L1711-L1747","documentation":"Generated app file paths (currently /wmill.d.ts) are regenerated from the app's backend runnables, so editing them directly would produce changes that are silently overwritten and desynced from the source of truth. assertNotGeneratedAppFile guards every app file write and throws this error when the target path is generated.","triggerScenarios":"Calling an app file edit/write tool targeting \"/wmill.d.ts\" (or any path in GENERATED_APP_FILE_PATHS) — e.g. the AI tries to fix a type error by hand-editing the generated declaration file.","commonSituations":"The model sees type errors in wmill.d.ts in editor output and tries to edit it; a bulk file operation sweeps generated paths; a refactor tool renames/moves files including generated ones.","solutions":["Do not edit the generated file; change the backend runnables in the app draft instead and let the file regenerate.","If a type mismatch needs fixing, adjust the runnable's input/output shapes or args, not the declaration file.","Pick a different file path for custom type declarations.","Filter generated paths out of any automated file-edit loop."],"exampleFix":"// before\nwriteAppFile('/wmill.d.ts', patchedDeclaration) // throws\n// after\nupdateBackendRunnable(draft, key, { args: fixedArgs }) // regenerates wmill.d.ts","handlingStrategy":"validation","validationCode":"const GENERATED = new Set(['/wmill.d.ts'])\nif (GENERATED.has(filePath)) {\n  console.warn('skipping generated file', filePath)\n  return\n}","typeGuard":"function isEditableAppFile(p: string): boolean {\n  return !GENERATED_APP_FILE_PATHS.has(p)\n}","tryCatchPattern":"try {\n  await writeAppFile(filePath, content)\n} catch (e) {\n  if (e.message.includes('generated automatically')) {\n    console.warn(`${filePath} is generated; modify the backend runnables instead`)\n  }\n}","preventionTips":["Filter GENERATED_APP_FILE_PATHS out of any batch file-edit loop","Fix type errors by changing backend runnable args/shapes, not the declaration file","Put custom declarations in a non-generated path"],"tags":["generated-code","write-protection","apps","ai-tools"],"backgroundTag":"generated-file-not-editable","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"}