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
- Ensure the JSON is an object with an operations array.
- Validate shape with a type guard before calling.
- 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
- Use detectAutomationFormat to route to the right parser.
- Reject array-shaped or empty files in the import UI.
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
- Invalid folder scanning config: expected JSON object
- Invalid folder scanning config: missing 'pipeline' array
- Invalid folder scanning config: pipeline[${index}] is not an
- Invalid folder scanning config: pipeline[${index}].operation
- Invalid automation config: missing 'operations' array
AI-assisted analysis of Stirling-Tools/Stirling-PDF@9ef20dcab8 (2026-08-13).
Data as JSON: /api/errors/1a06ad33f1ca06cc.
Report an issue: GitHub.