{"record":{"id":"89955ac1d61b0b47","repo":"windmill-labs/windmill","slug":"file-only-applies-to-multi-file-apps-type-p","errorCode":null,"errorMessage":"file only applies to multi-file apps; ${type} \"${path}\" diffs as a single document — call again without file.","messagePattern":"file only applies to multi-file apps; (.+?) \"(.+?)\" diffs as a single document — call again without file\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"frontend/src/lib/components/copilot/chat/global/core.ts","lineNumber":6657,"sourceCode":"\t\t}\n\t}\n\n\tconst changedFileCount = files ? Object.keys(files).length : 0\n\tif (!patch && changedFileCount === 0) {\n\t\t// A secret's sides are masked on both ends — an empty patch cannot prove\n\t\t// the value is unchanged.\n\t\tconst message = valueUncomparable\n\t\t\t? `No visible changes for ${type} \"${path}\" — but a secret's value cannot be compared and may have been updated in the draft.`\n\t\t\t: `Draft matches the deployed version of ${type} \"${path}\" — no changes.`\n\t\ttoolCallbacks.setToolStatus(toolId, { content: message, result: message })\n\t\treturn flushCaveat + message\n\t}\n\n\tconst header = noDeployed\n\t\t? `${type} \"${path}\" has no deployed version yet — the entire draft is new.\\n\\n`\n\t\t: `Draft changes vs deployed for ${type} \"${path}\":\\n\\n`\n\tif (args.file !== undefined && !files) {\n\t\tthrow new Error(\n\t\t\t`file only applies to multi-file apps; ${type} \"${path}\" diffs as a single document — call again without file.`\n\t\t)\n\t}\n\tconst body = files\n\t\t? renderEntryFiles(files, patch, args)\n\t\t: windowPatchBody(patch, args.offset ?? 0, args.limit ?? DIFF_READ_DEFAULT_LINES)\n\tconst result = flushCaveat + header + body\n\ttoolCallbacks.setToolStatus(toolId, {\n\t\tcontent: `Draft vs deployed diff for \"${path}\"`,\n\t\tresult\n\t})\n\treturn result\n}\n\n// Body of an item read for a multi-file app: one file's patch when `file` is\n// given, otherwise the per-file summary plus config changes.\nfunction renderEntryFiles(\n\tfiles: Record<string, DiffFileView>,","sourceCodeStart":6639,"sourceCodeEnd":6675,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/frontend/src/lib/components/copilot/chat/global/core.ts#L6639-L6675","documentation":"The `file` argument of the copilot diff tool narrows a diff to one file of a multi-file item (apps). When the computed diff produced no `files` map — the item is a single-document kind — passing `file` is invalid and the tool throws this corrective error telling the agent to retry without it. It is an argument-surface misuse guard, not a data failure.","triggerScenarios":"Calling diff with `args.file` set while the item is a single-document type (script, flow, variable, resource, etc.) or the diff entry has no files map, i.e. `args.file !== undefined && !files`.","commonSituations":"An agent habitually includes `file` from a previous app-diff call; a template call copied from an app example applied to a script; confusing multi-file apps with single-file scripts.","solutions":["Retry the same diff call without the `file` argument","If you need per-file output for a multi-file app, confirm the type is 'app' or 'raw_app' before passing `file`"],"exampleFix":"// before\ndiff({ type: 'script', path: 'f/build', file: 'main.ts' })\n// after\ndiff({ type: 'script', path: 'f/build' })","handlingStrategy":"validation","validationCode":"if (args.file !== undefined && !['app', 'raw_app'].includes(args.type)) {\n  throw new Error('file is only valid for app diffs')\n}","typeGuard":"function supportsFileFilter(args: { type: string; file?: string }): boolean {\n  return args.file === undefined || args.type === 'app' || args.type === 'raw_app'\n}","tryCatchPattern":"try {\n  return await diffItem(args)\n} catch (e) {\n  if (String(e?.message).startsWith('file only applies to multi-file apps')) {\n    return await diffItem({ ...args, file: undefined })\n  }\n  throw e\n}","preventionTips":["Only pass `file` when the type is 'app' or 'raw_app'","Drop the file argument when retrying after this error","Remember single-document kinds (script, flow, variable) never have a files map"],"tags":["arguments","validation","diff"],"backgroundTag":"invalid-tool-arguments","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"}