n8n-io/n8n · error · Error
Failed to parse CSV file
Error message
Failed to parse CSV file: ${message} What it means
Wrapper error from parseCsv in the CSV prompt loader. It fires when the csv-parse library throws while parsing the file content (malformed quoting, unexpected structure), and re-raises with the underlying parser message appended. The parser runs with relaxed settings (skip empty lines, relax column count), so this indicates real structural corruption rather than ordinary variation.
Solutions
- Fix the CSV syntax problem named in the wrapped message (unclosed quotes, inconsistent columns, bad encoding).
- Re-export the CSV with standard quoting (RFC 4180) and UTF-8 encoding.
- Validate the file with a CSV linter or open it in a spreadsheet tool to spot malformed rows.
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at packages/@n8n/ai-workflow-builder.ee/evaluations/cli/csv-prompt-loader.ts:38 when the library encounters an invalid state.
Common situations: See trigger scenarios.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12).
Data as JSON: /api/errors/d7ce7570d430d82c.
Report an issue: GitHub.
Appendix: source
Thrown at packages/@n8n/ai-workflow-builder.ee/evaluations/cli/csv-prompt-loader.ts:38
}
function sanitizeValue(value: string | undefined) {
return value?.trim() ?? '';
}
function parseCsv(content: string): ParsedCsvRow[] {
try {
const rows = parse(content.replace(/^\ufeff/, ''), {
columns: false,
skip_empty_lines: true,
trim: true,
relax_column_count: true,
}) as ParsedCsvRow[];
return rows.map((row) => row.map((cell) => cell ?? ''));
} catch (error) {
const message = error instanceof Error ? error.message : 'Unknown parsing error';
throw new Error(`Failed to parse CSV file: ${message}`);
}
}
export function loadTestCasesFromCsv(csvPath: string): TestCase[] {
const resolvedPath = isAbsolute(csvPath) ? csvPath : resolve(process.cwd(), csvPath);
if (!existsSync(resolvedPath)) {
throw new Error(`CSV file not found at ${resolvedPath}`);
}
const rows = parseCsv(readFileSync(resolvedPath, 'utf8'));
if (rows.length === 0) {
throw new Error('The provided CSV file is empty');
}
const hasHeader = isHeaderRow(rows[0]);
const header = hasHeader ? rows[0] : undefined;View on GitHub (pinned to 5ac6606e81)