Stirling-Tools/Stirling-PDF · warning · Error

Invalid automation config: expected JSON object

Error message

Invalid automation config: expected JSON object

What it means

Thrown by parseAutomationConfigJson when the parsed value is not a plain object (null, array, primitive). The native Automate format requires a top-level object with an operations array.

Source

Thrown at frontend/editor/src/core/utils/automationConverter.ts:317

    },
    unresolvedOperations: unresolved,
  };
}

/**
 * Parse a native Automate JSON file (a previously-exported AutomationConfig).
 * The id / createdAt / updatedAt fields are dropped — the storage layer
 * regenerates them on save.
 */
export function parseAutomationConfigJson(
  raw: unknown,
  toolRegistry: Partial<ToolRegistry>,
): {
  automation: Omit<AutomationConfig, "id" | "createdAt" | "updatedAt">;
  unresolvedOperations: string[];
} {
  if (!raw || typeof raw !== "object") {
    throw new Error("Invalid automation config: expected JSON object");
  }
  const obj = raw as Record<string, unknown>;
  const operations = obj.operations;
  if (!Array.isArray(operations)) {
    throw new Error("Invalid automation config: missing 'operations' array");
  }

  const unresolved: string[] = [];
  const parsedOperations: AutomationOperation[] = operations.map(
    (op: unknown, index: number) => {
      if (!op || typeof op !== "object") {
        throw new Error(
          `Invalid automation config: operations[${index}] is not an object`,
        );
      }
      const opObj = op as Record<string, unknown>;
      const operation = opObj.operation;
      if (typeof operation !== "string" || operation.length === 0) {

View on GitHub (pinned to 9ef20dcab8)

Solutions

  1. Ensure the JSON is an object with an operations array.
  2. Validate shape with a type guard before calling.
  3. Use detectAutomationFormat to confirm it is Automate format.

Example fix

// before
parseAutomationConfigJson(raw, toolRegistry);

// after
if (!raw || typeof raw !== 'object' || Array.isArray(raw)) {
  throw new Error('Automation config must be a JSON object with operations.');
}
parseAutomationConfigJson(raw, toolRegistry);
Defensive patterns

Strategy: validation

Validate before calling

if (!raw || typeof raw !== 'object' || Array.isArray(raw)) {
  throw new Error('Automation config must be a JSON object.');
}

Type guard

function isAutomationObject(raw: unknown): raw is Record<string, unknown> {
  return !!raw && typeof raw === 'object' && !Array.isArray(raw);
}

Prevention

When it happens

Trigger: The imported JSON is an array, a bare value, or null instead of the { operations: [...] } object.

Common situations: User imported an array of operations; an empty file; the wrong file selected.

Related errors


AI-assisted analysis of Stirling-Tools/Stirling-PDF@9ef20dcab8 (2026-08-13). Data as JSON: /api/errors/1a06ad33f1ca06cc. Report an issue: GitHub.