n8n-io/n8n · warning · Error

Access denied: "${excludedSegment}" is excluded from filesys

Error message

Access denied: "${excludedSegment}" is excluded from filesystem reads

What it means

Thrown by assertNoExcludedSegments() (called from resolveReadablePath) when the resolved path contains a directory segment matching an excluded name: node_modules, .git, dist, build, coverage, __pycache__, .venv, venv, .vscode, .idea, .next, .nuxt, .cache, .turbo, .output, .svelte-kit. The comparison is case-insensitive. resolveReadablePath runs this check on both the logical and real (symlink-resolved) paths, so symlinks into excluded directories are also caught.

Source

Thrown at packages/@n8n/computer-use/src/tools/filesystem/fs-utils.ts:146

		'.prettierrc.json',
		'.editorconfig',
		'.gitignore',
		'.dockerignore',
		'.nvmrc',
		'.node-version',
		'.npmrc',
		'.babelrc',
		'.browserslistrc',
	]);
	return allowed.has(name);
}

export function assertNoExcludedSegments(absolutePath: string, basePath: string): void {
	const relativePath = path.relative(path.resolve(basePath), path.resolve(absolutePath));
	const segments = relativePath.split(path.sep).filter(Boolean);
	const excludedSegment = segments.find(isExcludedDirName);
	if (excludedSegment) {
		throw new Error(`Access denied: "${excludedSegment}" is excluded from filesystem reads`);
	}
}

export function isExcludedDirName(segment: string): boolean {
	return NORMALIZED_EXCLUDED_DIRS.has(segment.toLowerCase());
}

export function isLikelyBinaryContent(buffer: Buffer): boolean {
	if (buffer.length === 0) return false;
	if (buffer.includes(0)) return true;

	try {
		utf8Decoder.decode(buffer);
	} catch {
		return true;
	}

	const checkSlice = buffer.subarray(0, Math.min(BINARY_CHECK_SIZE, buffer.length));

View on GitHub (pinned to 5ac6606e81)

Solutions

  1. Use the library's public type definitions or documentation instead of reading source in node_modules
  2. Copy the specific needed file into the base directory if read access is essential
  3. Check the EXCLUDED_DIRS set in fs-utils.ts to see which directory names are blocked
  4. Use search_files with a pattern that excludes the blocked directory
Defensive patterns

Strategy: validation

Validate before calling

import { EXCLUDED_DIRS } from './fs-utils';

function containsExcludedSegment(relativePath: string): string | null {
  const excluded = new Set([...EXCLUDED_DIRS].map(d => d.toLowerCase()));
  const segment = relativePath.split('/').find(s => excluded.has(s.toLowerCase()));
  return segment ?? null;
}

// Before calling read_file or search_files:
const blocked = containsExcludedSegment(filePath);
if (blocked) {
  throw new Error(`Cannot read inside excluded directory: ${blocked}`);
}

Type guard

function isExcludedSegmentError(e: unknown): boolean {
  return e instanceof Error && e.message.startsWith('Access denied:') && e.message.includes('is excluded from filesystem reads');
}

Prevention

When it happens

Trigger: A read_file or search_files call targets a path inside node_modules/, .git/, dist/, or any other excluded directory. Also fires if a symlink resolves into an excluded directory.

Common situations: Agent tries to read a library source file in node_modules to understand an API, or tries to read .git internals, or accesses a build output in dist/.

Understand the failure class

Related errors


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