n8n-io/n8n · error · UserError

File does not seem to contain valid workflows.

Error message

File does not seem to contain valid workflows.

What it means

Thrown by assertHasWorkflowsToImport when any element of the parsed workflow array is not an object, or is missing the required `nodes` or `connections` properties. The type assertion guard (workflow.ts:25-37) validates workflow file shape before entity creation.

Source

Thrown at packages/cli/src/commands/import/workflow.ts:34

import { z } from 'zod';

import { UM_FIX_INSTRUCTION } from '@/constants';
import { EventService } from '@/events/event.service';
import type { IWorkflowToImport, IWorkflowWithVersionMetadata } from '@/interfaces';
import { ImportService } from '@/services/import.service';

import { BaseCommand } from '../base-command';

function assertHasWorkflowsToImport(
	workflows: unknown[],
): asserts workflows is IWorkflowToImport[] {
	for (const workflow of workflows) {
		if (
			typeof workflow !== 'object' ||
			!Object.prototype.hasOwnProperty.call(workflow, 'nodes') ||
			!Object.prototype.hasOwnProperty.call(workflow, 'connections')
		) {
			throw new UserError('File does not seem to contain valid workflows.');
		}
	}
}

/**
 * Creates workflow entities from plain objects while preserving versionMetadata metadata.
 */
function createWorkflowsWithVersionMetadata(
	workflowRepository: WorkflowRepository,
	workflows: IWorkflowToImport[],
): IWorkflowWithVersionMetadata[] {
	const createdWorkflows = workflowRepository.create(workflows);
	return createdWorkflows.map((created, index) => ({
		...created,
		versionMetadata: workflows[index].versionMetadata,
	}));
}

View on GitHub (pinned to 5ac6606e81)

Solutions

  1. Ensure each workflow object has `nodes` (array) and `connections` (object) keys — the two required fields.
  2. Open the JSON in an editor and verify the shape matches a workflow export.
  3. If using --separate, invalid files are skipped with a warning; check the log for 'Skipping invalid workflow file'.

Example fix

// before — missing connections
{ "name": "My WF", "nodes": [...] }
// after
{ "name": "My WF", "nodes": [...], "connections": {} }
Defensive patterns

Strategy: type-guard

Validate before calling

function isValidWorkflowImport(w: unknown): w is { nodes: unknown; connections: unknown } {
  return typeof w === 'object' && w !== null &&
    Object.prototype.hasOwnProperty.call(w, 'nodes') &&
    Object.prototype.hasOwnProperty.call(w, 'connections');
}
function validateWorkflows(arr: unknown[]) {
  for (const w of arr) if (!isValidWorkflowImport(w)) {
    throw new Error('Each entry must have nodes and connections');
  }
}
validateWorkflows(parsedArray);

Type guard

function isWorkflowImport(w: unknown): w is { nodes: unknown[]; connections: Record<string, unknown> } {
  return typeof w === 'object' && w !== null &&
    'nodes' in w && 'connections' in w;
}

Prevention

When it happens

Trigger: Importing a JSON file (single or `--separate`) whose contents lack `nodes` and/or `connections` keys, or contain a non-object entry (e.g. a string or number in the array). Fires from readWorkflows for both single-file and per-file modes (though per-file mode catches and warns, line 278-281, instead of throwing).

Common situations: Using a credential export file as a workflow import; partial/corrupt export; hand-crafted JSON missing the connections field; wrong file passed to --input.

Related errors


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