{"record":{"id":"b44e31a24fc2153d","repo":"n8n-io/n8n","slug":"failed-to-parse-label-at-path-msg","errorCode":null,"errorMessage":"Failed to parse ${label} at ${path}: ${msg}","messagePattern":"Failed to parse (.+?) at (.+?): (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/@n8n/instance-ai/evaluations/cli/build-mcp-manifest.ts","lineNumber":253,"sourceCode":"\t}\n\n\tmkdirSync(result.outputDir, { recursive: true });\n\tif (!result.manifestPath) result.manifestPath = join(result.outputDir, 'manifest.json');\n\tif (!result.logDir) result.logDir = join(result.outputDir, 'logs');\n\tconst base = result.manifestPath.replace(/\\.json$/, '');\n\tresult.statsPath = `${base}-stats.json`;\n\tmkdirSync(result.logDir, { recursive: true });\n\n\treturn { helpRequested: false, args: result };\n}\n\nfunction readJson(path: string, label: string): unknown {\n\tconst content = readFileSync(path, 'utf-8');\n\ttry {\n\t\treturn JSON.parse(content);\n\t} catch (error) {\n\t\tconst msg = error instanceof Error ? error.message : String(error);\n\t\tthrow new Error(`Failed to parse ${label} at ${path}: ${msg}`);\n\t}\n}\n\nfunction nextArg(argv: string[], i: number, flag: string): string {\n\tconst value = argv[i + 1];\n\tif (value === undefined || value.startsWith('--')) {\n\t\tthrow new Error(`Missing value for ${flag}`);\n\t}\n\treturn value;\n}\n\nfunction parseIntArg(argv: string[], i: number, flag: string): number {\n\tconst raw = nextArg(argv, i, flag);\n\tconst parsed = parseInt(raw, 10);\n\tif (Number.isNaN(parsed)) throw new Error(`Invalid integer for ${flag}`);\n\treturn parsed;\n}\n","sourceCodeStart":235,"sourceCodeEnd":271,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/instance-ai/evaluations/cli/build-mcp-manifest.ts#L235-L271","documentation":"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).","triggerScenarios":"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.","commonSituations":"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.","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>"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Pre-validate JSON files before the CLI reads them:\nimport { readFileSync } from 'fs';\nfunction assertValidJson(path: string): void {\n  try {\n    JSON.parse(readFileSync(path, 'utf-8'));\n  } catch (e) {\n    throw new Error(`Pre-check failed: ${path} is not valid JSON: ${(e as Error).message}`);\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  const data = JSON.parse(content);\n} catch (error) {\n  const msg = error instanceof Error ? error.message : String(error);\n  throw new Error(`Failed to parse ${label} at ${path}: ${msg}`);\n}","preventionTips":["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"],"tags":["json","filesystem","validation","build-mcp-manifest","data-integrity"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}