{"record":{"id":"1f276b5998024571","repo":"Stirling-Tools/Stirling-PDF","slug":"invalid-folder-scanning-config-expected-json-obje","errorCode":null,"errorMessage":"Invalid folder scanning config: expected JSON object","messagePattern":"Invalid folder scanning config: expected JSON object","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"frontend/editor/src/core/utils/automationConverter.ts","lineNumber":231,"sourceCode":"  candidate: string,\n  toolRegistry: Partial<ToolRegistry>,\n): boolean => Object.prototype.hasOwnProperty.call(toolRegistry, candidate);\n\n/**\n * Parse a folder-scanning pipeline JSON into the native AutomationConfig\n * shape. Endpoint paths are reverse-mapped to frontend tool IDs via the\n * supplied registry; unmappable operations are kept verbatim and reported in\n * `unresolvedOperations`.\n */\nexport function parseFolderScanningConfig(\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 folder scanning config: expected JSON object\");\n  }\n  const obj = raw as Record<string, unknown>;\n  const pipeline = obj.pipeline;\n  if (!Array.isArray(pipeline)) {\n    throw new Error(\"Invalid folder scanning config: missing 'pipeline' array\");\n  }\n\n  const endpointMap = buildEndpointToToolIdMap(toolRegistry);\n  const unresolved: string[] = [];\n\n  const operations: AutomationOperation[] = pipeline.map(\n    (step: unknown, index: number) => {\n      if (!step || typeof step !== \"object\") {\n        throw new Error(\n          `Invalid folder scanning config: pipeline[${index}] is not an object`,\n        );\n      }\n      const stepObj = step as Record<string, unknown>;","sourceCodeStart":213,"sourceCodeEnd":249,"githubUrl":"https://github.com/Stirling-Tools/Stirling-PDF/blob/9ef20dcab80b85041912f045e17a6aea1d08f969/frontend/editor/src/core/utils/automationConverter.ts#L213-L249","documentation":"Thrown by parseFolderScanningConfig when the parsed value is not a plain object: it is null, an array, a primitive, or undefined. The folder-scanning format requires a top-level object containing a pipeline array.","triggerScenarios":"The imported JSON is an array of steps rather than the wrapper object, an empty/null file, or a bare primitive value.","commonSituations":"User selected a JSON that is an array of operations instead of the { pipeline: [...] } object; an empty file parsed to null; the wrong file was selected.","solutions":["Ensure the JSON is an object with a top-level pipeline array.","Validate the shape with a type guard before calling parseFolderScanningConfig.","Use detectAutomationFormat first to confirm the file is folder-scanning."],"exampleFix":"// before\nparseFolderScanningConfig(raw, toolRegistry);\n\n// after\nif (!raw || typeof raw !== 'object' || Array.isArray(raw)) {\n  throw new Error('Select a folder-scanning config object with a pipeline array.');\n}\nparseFolderScanningConfig(raw, toolRegistry);","handlingStrategy":"validation","validationCode":"if (!raw || typeof raw !== 'object' || Array.isArray(raw)) {\n  throw new Error('Folder scanning config must be a JSON object.');\n}","typeGuard":"function isFolderScanningObject(raw: unknown): raw is Record<string, unknown> {\n  return !!raw && typeof raw === 'object' && !Array.isArray(raw);\n}","tryCatchPattern":null,"preventionTips":["Run detectAutomationFormat on imported JSON and only call the matching parser.","Reject array-shaped or empty files in the import UI before parsing."],"tags":["automation","config","validation","json","folder-scanning"],"backgroundTag":null,"analyzedSha":"9ef20dcab80b85041912f045e17a6aea1d08f969","analyzedAt":"2026-08-13T22:11:39.827Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}