{"record":{"id":"1a06ad33f1ca06cc","repo":"Stirling-Tools/Stirling-PDF","slug":"invalid-automation-config-expected-json-object","errorCode":null,"errorMessage":"Invalid automation config: expected JSON object","messagePattern":"Invalid automation config: expected JSON object","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"frontend/editor/src/core/utils/automationConverter.ts","lineNumber":317,"sourceCode":"    },\n    unresolvedOperations: unresolved,\n  };\n}\n\n/**\n * Parse a native Automate JSON file (a previously-exported AutomationConfig).\n * The id / createdAt / updatedAt fields are dropped — the storage layer\n * regenerates them on save.\n */\nexport function parseAutomationConfigJson(\n  raw: unknown,\n  toolRegistry: Partial<ToolRegistry>,\n): {\n  automation: Omit<AutomationConfig, \"id\" | \"createdAt\" | \"updatedAt\">;\n  unresolvedOperations: string[];\n} {\n  if (!raw || typeof raw !== \"object\") {\n    throw new Error(\"Invalid automation config: expected JSON object\");\n  }\n  const obj = raw as Record<string, unknown>;\n  const operations = obj.operations;\n  if (!Array.isArray(operations)) {\n    throw new Error(\"Invalid automation config: missing 'operations' array\");\n  }\n\n  const unresolved: string[] = [];\n  const parsedOperations: AutomationOperation[] = operations.map(\n    (op: unknown, index: number) => {\n      if (!op || typeof op !== \"object\") {\n        throw new Error(\n          `Invalid automation config: operations[${index}] is not an object`,\n        );\n      }\n      const opObj = op as Record<string, unknown>;\n      const operation = opObj.operation;\n      if (typeof operation !== \"string\" || operation.length === 0) {","sourceCodeStart":299,"sourceCodeEnd":335,"githubUrl":"https://github.com/Stirling-Tools/Stirling-PDF/blob/9ef20dcab80b85041912f045e17a6aea1d08f969/frontend/editor/src/core/utils/automationConverter.ts#L299-L335","documentation":"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.","triggerScenarios":"The imported JSON is an array, a bare value, or null instead of the { operations: [...] } object.","commonSituations":"User imported an array of operations; an empty file; the wrong file selected.","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."],"exampleFix":"// before\nparseAutomationConfigJson(raw, toolRegistry);\n\n// after\nif (!raw || typeof raw !== 'object' || Array.isArray(raw)) {\n  throw new Error('Automation config must be a JSON object with operations.');\n}\nparseAutomationConfigJson(raw, toolRegistry);","handlingStrategy":"validation","validationCode":"if (!raw || typeof raw !== 'object' || Array.isArray(raw)) {\n  throw new Error('Automation config must be a JSON object.');\n}","typeGuard":"function isAutomationObject(raw: unknown): raw is Record<string, unknown> {\n  return !!raw && typeof raw === 'object' && !Array.isArray(raw);\n}","tryCatchPattern":null,"preventionTips":["Use detectAutomationFormat to route to the right parser.","Reject array-shaped or empty files in the import UI."],"tags":["automation","config","validation","json"],"backgroundTag":null,"analyzedSha":"9ef20dcab80b85041912f045e17a6aea1d08f969","analyzedAt":"2026-08-13T22:11:39.827Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}