n8n-io/n8n · error
File "${input.path}" is not loaded.
Error message
File "${input.path}" is not loaded. What it means
In the str-replace-file tool, after readFile sets initialText and editor.execute() runs the 'str_replace' command, getText() must return the edited string. If it returns null the document is somehow unloaded — an invariant violation of TextEditorDocument that is not reachable in normal flow (initialText was just provided). The throw prevents writing `null` to the file.
Source
Thrown at packages/@n8n/agents/src/workspace/tools/str-replace-file.ts:52
)
.input(inputSchema)
.output(outputSchema)
.handler(async (input, ctx) => {
try {
const content = await filesystem.readFile(input.path, {
encoding: 'utf-8',
abortSignal: ctx.abortSignal,
});
const editor = new TextEditorDocument({ initialText: content.toString() });
const result = editor.execute({
command: 'str_replace',
path: input.path,
old_str: input.old_str,
new_str: input.new_str,
});
const editedContent = editor.getText();
if (editedContent === null) {
throw new Error(`File "${input.path}" is not loaded.`);
}
await filesystem.writeFile(input.path, editedContent, {
overwrite: true,
abortSignal: ctx.abortSignal,
});
return { success: true, result };
} catch (error) {
if (isAbortError(error)) throw error;
return createErrorOutput(error);
}
})
.build();
}
View on GitHub (pinned to 5ac6606e81)
Solutions
- Report as an internal bug in @n8n/agents with the path and old_str/new_str.
- Retry with a fresh TextEditorDocument instance.
- Confirm old_str actually exists in the file — a no-op match shouldn't null the buffer, but verify the editor version is current.
Defensive patterns
Strategy: try-catch
Try / catch
try {
return await strReplaceFile(...);
} catch (e) {
if (e instanceof Error && /is not loaded/.test(e.message)) {
// internal invariant — retry with a fresh TextEditorDocument
} else throw e;
} Prevention
- Treat 'is not loaded' as an internal bug — report it with path + old_str/new_str.
- Don't share a TextEditorDocument instance across operations.
- Verify old_str exists in the file before calling.
When it happens
Trigger: Not reachable in normal use — initialText is set from the file content immediately before. Would only fire on a TextEditorDocument regression where execute() clears the buffer, or if the editor instance is shared/concurrently mutated.
Common situations: A bug in TextEditorDocument.execute() that nulls internal state; reusing one editor across files; future refactor breaking the loaded-text invariant.
Related errors
- File "${input.path}" is not loaded.
- Sandbox does not support command execution
- Deferred tool name "${tool.name}" is reserved
- Duplicate deferred tool name "${tool.name}"
- ${toolName} policy.maxChildren must be a finite positive int
AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12).
Data as JSON: /api/errors/fa786d537eb0ce95.
Report an issue: GitHub.