n8n-io/n8n · error · Error

Existing manifest at ${manifestPath} is malformed; remove or

Error message

Existing manifest at ${manifestPath} is malformed; remove or fix it before re-running:\n  ${msg}

What it means

The readExistingWorkflows function (line 338) reads a previously-written manifest to merge or update it. It parses the file through the prebuiltManifestSchema Zod schema to ensure the structure matches what the eval loader expects. If JSON parsing or Zod validation fails, the error is thrown rather than silently treating the file as empty — silently empty would clobber accumulated workflow entries on the next write, which is especially destructive with --append where the entire prior corpus could be lost.

Source

Thrown at packages/@n8n/instance-ai/evaluations/cli/build-mcp-manifest.ts:348

		durationMs: result.durationMs,
	};
}

// ---------------------------------------------------------------------------
// Manifest + stats output
// ---------------------------------------------------------------------------

function readExistingWorkflows(manifestPath: string): Record<string, string[]> {
	if (!existsSync(manifestPath)) return {};
	// The file exists — it must be parseable. Silently treating a malformed
	// manifest as empty would clobber accumulated entries on the next write
	// (especially destructive with --append, where the entire prior corpus
	// could be lost). Force the user to fix or remove the file first.
	try {
		return { ...prebuiltManifestSchema.parse(readJson(manifestPath, 'existing manifest')) };
	} catch (error) {
		const msg = error instanceof Error ? error.message : String(error);
		throw new Error(
			`Existing manifest at ${manifestPath} is malformed; remove or fix it before re-running:\n  ${msg}`,
		);
	}
}

function writeManifest(args: CliArgs, results: BuildOutcome[]): void {
	const workflows = readExistingWorkflows(args.manifestPath);

	if (!args.append) {
		// Without --append, clear entries for slugs we just rebuilt; preserve
		// other slugs in the existing manifest.
		for (const slug of new Set(results.map((r) => r.slug))) {
			delete workflows[slug];
		}
	}

	for (const r of results) {
		if (!r.workflowId) continue;

View on GitHub (pinned to 5ac6606e81)

Solutions

  1. Delete the malformed manifest and re-run: rm <manifest-path>
  2. Fix the JSON syntax or schema shape — the error message includes the underlying parse/schema detail
  3. Use --manifest to write to a different path, preserving the old file
  4. Restore from git if committed: git checkout -- <manifest-path>

Example fix

# before: manifest.json is truncated/corrupt from a crashed run
# after
rm manifest.json && pnpm eval:build-mcp-manifest
Defensive patterns

Strategy: validation

Validate before calling

// Pre-validate an existing manifest against the Zod schema before running:
import { readFileSync } from 'fs';
import { prebuiltManifestSchema } from '../harness/prebuilt-workflows';
try {
  prebuiltManifestSchema.parse(JSON.parse(readFileSync(manifestPath, 'utf-8')));
} catch (e) {
  console.error(`Manifest is malformed, removing: ${manifestPath}`);
  // rmSync(manifestPath);
}

Try / catch

try {
  return prebuiltManifestSchema.parse(readJson(manifestPath, 'existing manifest'));
} catch (error) {
  const msg = error instanceof Error ? error.message : String(error);
  throw new Error(`Existing manifest at ${manifestPath} is malformed; remove or fix it: ${msg}`);
}

Prevention

When it happens

Trigger: The manifest file at --manifest (default <output-dir>/manifest.json) exists but is either not valid JSON or does not match the prebuiltManifestSchema shape (an object mapping slug to an array of workflow-id strings). This occurs when the file was hand-edited, partially written by a crashed run, or is from an incompatible older schema version.

Common situations: A previous build run crashed mid-write leaving a truncated manifest. The manifest was manually edited and broken. A schema change in prebuiltManifestSchema made an older manifest invalid. A git merge left conflict markers in the file.

Understand the failure class

Related errors


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