n8n-io/n8n · error

Failed to write sandbox workspace file

Error message

Failed to write sandbox workspace file "${path}": ${getErrorMessage(error)}; command fallback failed: ${getErrorMessage(fallbackError)}

What it means

writeWorkspaceFile attempted filesystem.writeFile and, when that threw, the base64 shell write via writeFileViaSandbox; both failed. The message names the file path and chains the API error and the fallback command error together.

Solutions

  1. Inspect both chained messages to isolate whether the filesystem or the shell path is broken
  2. Retry after restoring sandbox I/O health
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at packages/@n8n/instance-ai/src/workspace/sandbox-setup.ts:376 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12). Data as JSON: /api/errors/66c9f59913ee836c. Report an issue: GitHub.

Appendix: source

Thrown at packages/@n8n/instance-ai/src/workspace/sandbox-setup.ts:376

				`Failed to create sandbox workspace directory "${path}": ${getErrorMessage(error)}; command fallback failed: ${getErrorMessage(fallbackError)}`,
			);
		}
	}
}

async function writeWorkspaceFile(
	workspace: SandboxWorkspace,
	filesystem: WorkspaceFilesystem,
	path: string,
	content: string | Buffer,
): Promise<void> {
	try {
		await filesystem.writeFile(path, content, { recursive: true });
	} catch (error) {
		try {
			await writeFileViaSandbox(workspace, path, content);
		} catch (fallbackError) {
			throw new Error(
				`Failed to write sandbox workspace file "${path}": ${getErrorMessage(error)}; command fallback failed: ${getErrorMessage(fallbackError)}`,
			);
		}
	}
}

async function readWorkspaceFile(
	workspace: SandboxWorkspace,
	path: string,
): Promise<string | null> {
	const filesystem = workspace.filesystem;
	if (filesystem?.readFile) {
		try {
			const content = await filesystem.readFile(path, { encoding: 'utf-8' });
			return typeof content === 'string' ? content : content.toString('utf-8');
		} catch {
			if (!workspace.sandbox) return null;
		}

View on GitHub (pinned to 5ac6606e81)