windmill-labs/windmill · error · Error

"${filePath}" is generated automatically from backend runnab

Error message

"${filePath}" is generated automatically from backend runnables and cannot be modified directly.

What it means

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.

Source

Thrown at frontend/src/lib/components/copilot/chat/global/core.ts:1729

		...(value.data && { data: value.data })
	}
}

function appToItem(app: ListableApp | AppWithLastVersion, includeValue: boolean): WorkspaceItem {
	return {
		type: 'app',
		path: app.path,
		summary: app.summary,
		value: includeValue ? ((app as AppWithLastVersion).value as AppDraftValue) : undefined,
		isDraft: false
	}
}

const GENERATED_APP_FILE_PATHS = new Set(['/wmill.d.ts'])

function assertNotGeneratedAppFile(filePath: string): void {
	if (GENERATED_APP_FILE_PATHS.has(filePath)) {
		throw new Error(
			`"${filePath}" is generated automatically from backend runnables and cannot be modified directly.`
		)
	}
}

type AppFileTarget =
	| { kind: 'frontend'; filePath: string }
	| { kind: 'backend'; filePath: string; key: string; extension: 'ts' | 'py' }

function resolveAppFileTarget(rawPath: string): AppFileTarget {
	const trimmed = rawPath.trim()
	const backendMatch = trimmed.match(/^backend\/([^/]+)\/main\.(ts|py)$/)
	if (backendMatch) {
		return {
			kind: 'backend',
			filePath: trimmed,
			key: backendMatch[1],
			extension: backendMatch[2] as 'ts' | 'py'

View on GitHub (pinned to e474e8803c)

Solutions

  1. Do not edit the generated file; change the backend runnables in the app draft instead and let the file regenerate.
  2. If a type mismatch needs fixing, adjust the runnable's input/output shapes or args, not the declaration file.
  3. Pick a different file path for custom type declarations.
  4. Filter generated paths out of any automated file-edit loop.

Example fix

// before
writeAppFile('/wmill.d.ts', patchedDeclaration) // throws
// after
updateBackendRunnable(draft, key, { args: fixedArgs }) // regenerates wmill.d.ts
Defensive patterns

Strategy: validation

Validate before calling

const GENERATED = new Set(['/wmill.d.ts'])
if (GENERATED.has(filePath)) {
  console.warn('skipping generated file', filePath)
  return
}

Type guard

function isEditableAppFile(p: string): boolean {
  return !GENERATED_APP_FILE_PATHS.has(p)
}

Try / catch

try {
  await writeAppFile(filePath, content)
} catch (e) {
  if (e.message.includes('generated automatically')) {
    console.warn(`${filePath} is generated; modify the backend runnables instead`)
  }
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of windmill-labs/windmill@e474e8803c (2026-09-03). Data as JSON: /api/errors/f2579d8af124850a. Report an issue: GitHub.