n8n-io/n8n · error · Error
Failed to parse ${label} at ${path}: ${msg}
Error message
Failed to parse ${label} at ${path}: ${msg} What it means
The readJson helper (line 247) reads a file and calls JSON.parse on its contents. When parsing fails, the original SyntaxError message is wrapped with the file path and a human label (e.g. 'test case', 'existing manifest') so the developer knows exactly which file is malformed and why. This is called from multiple sites: test-case loading (line 504), tier-dataset reading (line 423), and existing-manifest reading (line 345).
Source
Thrown at packages/@n8n/instance-ai/evaluations/cli/build-mcp-manifest.ts:253
}
mkdirSync(result.outputDir, { recursive: true });
if (!result.manifestPath) result.manifestPath = join(result.outputDir, 'manifest.json');
if (!result.logDir) result.logDir = join(result.outputDir, 'logs');
const base = result.manifestPath.replace(/\.json$/, '');
result.statsPath = `${base}-stats.json`;
mkdirSync(result.logDir, { recursive: true });
return { helpRequested: false, args: result };
}
function readJson(path: string, label: string): unknown {
const content = readFileSync(path, 'utf-8');
try {
return JSON.parse(content);
} catch (error) {
const msg = error instanceof Error ? error.message : String(error);
throw new Error(`Failed to parse ${label} at ${path}: ${msg}`);
}
}
function nextArg(argv: string[], i: number, flag: string): string {
const value = argv[i + 1];
if (value === undefined || value.startsWith('--')) {
throw new Error(`Missing value for ${flag}`);
}
return value;
}
function parseIntArg(argv: string[], i: number, flag: string): number {
const raw = nextArg(argv, i, flag);
const parsed = parseInt(raw, 10);
if (Number.isNaN(parsed)) throw new Error(`Invalid integer for ${flag}`);
return parsed;
}
View on GitHub (pinned to 5ac6606e81)
Solutions
- Open the file at the path shown in the error and fix the JSON syntax error described in the message
- If it is a truncated manifest from a crashed run, delete it and re-run (or use --manifest with a fresh path)
- Restore a corrupt test case from git: git checkout -- <path>
- Validate the file with a JSON linter: npx prettier --check <path> or jq . <path>
Defensive patterns
Strategy: try-catch
Validate before calling
// Pre-validate JSON files before the CLI reads them:
import { readFileSync } from 'fs';
function assertValidJson(path: string): void {
try {
JSON.parse(readFileSync(path, 'utf-8'));
} catch (e) {
throw new Error(`Pre-check failed: ${path} is not valid JSON: ${(e as Error).message}`);
}
} Try / catch
try {
const data = JSON.parse(content);
} catch (error) {
const msg = error instanceof Error ? error.message : String(error);
throw new Error(`Failed to parse ${label} at ${path}: ${msg}`);
} Prevention
- Never hand-edit JSON test case files without a JSON-aware editor or validator
- Run prettier --check or jq . on test case files before committing
- Use atomic writes (write to temp, rename) to avoid truncated files from crashed runs
When it happens
Trigger: A test case JSON file (data/workflows/*.json), the manifest file, or any JSON read by the CLI contains invalid JSON syntax — trailing comma, unquoted keys, truncated content from a partial write, BOM character, or corrupted encoding.
Common situations: A previous build run crashed mid-write leaving a truncated JSON file. A hand-edited test case has a syntax error. A merge conflict left conflict markers inside a JSON file. An encoding issue introduced a BOM or control characters.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- Existing manifest at ${manifestPath} is malformed; remove or
- Workflow directory not found: ${workflowDir}
- --build-cwd directory does not exist: ${args.buildCwd}
- Invalid skill at ${sourceDirectory}: ${errors.join('; ')}
- File too large: ${stat.size} bytes (max ${MAX_FILE_SIZE} byt
AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12).
Data as JSON: /api/errors/b44e31a24fc2153d.
Report an issue: GitHub.