windmill-labs/windmill · error

Frontend file "${target.filePath}" not found in app "${path}

Error message

Frontend file "${target.filePath}" not found in app "${path}".

What it means

Thrown when reading a file's content as part of an edit/overwrite operation: for frontend targets, the draft's `files` map has no entry under target.filePath, so there is no current content to base the edit on. The tool refuses to proceed rather than silently creating a file.

Source

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

		replace_all: replaceAll
	} = args
	const target = resolveAppFileTarget(filePath)
	if (target.kind === 'frontend') {
		assertNotGeneratedAppFile(target.filePath)
	}

	toolCallbacks.setToolStatus(toolId, {
		content: `Patching ${target.filePath} in app "${path}"...`
	})

	const { value } = await loadAppDraftValue(path, workspace)
	let currentContent: string
	let runnable: PersistedRunnable | undefined

	if (target.kind === 'frontend') {
		const existing = value.files[target.filePath]
		if (existing === undefined) {
			throw new Error(`Frontend file "${target.filePath}" not found in app "${path}".`)
		}
		currentContent = existing
	} else {
		const resolved = getInlineRunnableContent(value, target, path)
		currentContent = resolved.content
		runnable = resolved.runnable
	}

	const updated = findAndReplace(
		currentContent,
		oldString,
		newString,
		replaceAll,
		`${target.filePath} content`
	)

	if (target.kind === 'frontend') {
		value.files = { ...value.files, [target.filePath]: updated }

View on GitHub (pinned to e474e8803c)

Solutions

  1. List the app's actual frontend files and retry with an existing path
  2. If the intent is to create a new file, use a create/write tool rather than an edit tool
  3. Check path casing and app-relative path format

Example fix

// before
edit_app_file({ path: 'f/app_main', file_path: 'src/Header.svelte', ... }) // missing
// after
write_app_file({ path: 'f/app_main', file_path: 'src/Header.svelte', content: '...' })
Defensive patterns

Strategy: validation

Validate before calling

const { value } = await loadAppDraftValue(path, workspace)
const existing = value.files[target.filePath]
if (existing === undefined) {
  // use a create/write tool instead of an edit tool
}

Type guard

function hasFile(files: Record<string, string>, p: string): boolean {
  return p in files
}

Try / catch

try {
  await editAppFile(args)
} catch (e) {
  if (e instanceof Error && e.message.includes('not found in app')) {
    await writeAppFile({ path: args.path, file_path: args.file_path, content: newContent })
  }
}

Prevention

When it happens

Trigger: An edit/patch-style tool call (one that reads current content before writing) targets a frontend file that is absent from the app draft — wrong path, deleted file, or file that only exists in the deployed version.

Common situations: Model edits a file it saw in the deployed app but that was renamed/removed in the draft; path casing mismatch; the file was never created and an edit tool was used instead of a create tool.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


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