{"record":{"id":"42bf973b4e28fb95","repo":"Egonex-AI/Understand-Anything","slug":"invalid-input-must-contain-projectroot-and-batchf","errorCode":null,"errorMessage":"Invalid input: must contain projectRoot and batchFiles array","messagePattern":"Invalid input: must contain projectRoot and batchFiles array","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"understand-anything-plugin/skills/understand/extract-structure.mjs","lineNumber":71,"sourceCode":"const { TreeSitterPlugin, PluginRegistry, builtinLanguageConfigs, registerAllParsers } = core;\n\n// ---------------------------------------------------------------------------\n// Main\n// ---------------------------------------------------------------------------\nasync function main() {\n  const [,, inputPath, outputPath] = process.argv;\n  if (!inputPath || !outputPath) {\n    process.stderr.write('Usage: node extract-structure.mjs <input.json> <output.json>\\n');\n    process.exit(1);\n  }\n\n  // Read input\n  const inputRaw = readFileSync(inputPath, 'utf-8');\n  const input = JSON.parse(inputRaw);\n  const { projectRoot, batchFiles, batchImportData } = input;\n\n  if (!projectRoot || !Array.isArray(batchFiles)) {\n    throw new Error('Invalid input: must contain projectRoot and batchFiles array');\n  }\n\n  // Create tree-sitter plugin with all configs that have WASM grammars\n  const tsConfigs = builtinLanguageConfigs.filter(c => c.treeSitter);\n  const tsPlugin = new TreeSitterPlugin(tsConfigs);\n  await tsPlugin.init();\n\n  // Create registry and register tree-sitter + all non-code parsers\n  const registry = new PluginRegistry();\n  registry.register(tsPlugin);\n  registerAllParsers(registry);\n\n  const results = [];\n  const filesSkipped = [];\n  const analysisOutcomes = {\n    structure: { succeeded: 0, failed: 0 },\n    callGraph: { succeeded: 0, failed: 0, skipped: 0 },\n  };","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/Egonex-AI/Understand-Anything/blob/32944829e7a63a9fa9c55d811d7f98a9530c6a6a/understand-anything-plugin/skills/understand/extract-structure.mjs#L53-L89","documentation":"Thrown by extract-structure.mjs main() after parsing its input JSON. It requires projectRoot (truthy) and batchFiles (an Array); batchImportData is destructured but optional. Aborts before constructing the tree-sitter plugin since without a file list there is nothing to analyze.","triggerScenarios":"process.argv lacks inputPath/outputPath (caught earlier). This throw fires when the parsed input JSON omits projectRoot, or batchFiles is not an array — e.g. field named files or batch instead of batchFiles, or batchFiles passed as a single string path.","commonSituations":"The batching driver emitted { files: [...] } instead of { batchFiles: [...] } (note the sibling workers use files / sourceFilePaths; this one is batchFiles). Truncated/empty input. Version drift between the batcher that writes inputs and this worker's schema. Hand-edited input missing projectRoot.","solutions":["Open the input JSON and confirm { projectRoot: <string>, batchFiles: [<string>, ...] }.","If the producer used files, rename to batchFiles for this worker (or fix the producer to emit the correct name).","Ensure projectRoot is a non-empty string and batchFiles is an array.","Re-run the batching stage so it emits batchFiles in the shape this worker expects."],"exampleFix":"// before — wrong field name\n{ \"projectRoot\": \"./repo\", \"files\": [\"./a.ts\"] }\n\n// after — this worker expects `batchFiles`\n{ \"projectRoot\": \"./repo\", \"batchFiles\": [\"./a.ts\"] }","handlingStrategy":"validation","validationCode":"import { readFileSync } from 'node:fs';\nfunction readStructureInput(inputPath) {\n  const raw = JSON.parse(readFileSync(inputPath, 'utf-8'));\n  if (!raw.projectRoot) throw new Error('input missing projectRoot');\n  if (!Array.isArray(raw.batchFiles)) throw new Error('batchFiles must be an array');\n  return raw;\n}","typeGuard":"function isStructureInput(v) {\n  return v !== null && typeof v === 'object'\n    && typeof v.projectRoot === 'string' && v.projectRoot.length > 0\n    && Array.isArray(v.batchFiles)\n    && v.batchFiles.every((f) => typeof f === 'string');\n}","tryCatchPattern":"try {\n  const input = readStructureInput(inputPath);\n} catch (e) {\n  process.stderr.write(`extract-structure input invalid: ${e.message}\\n`);\n  process.exit(1);\n}","preventionTips":["This worker expects `batchFiles` (not files, not sourceFilePaths).","Have the batcher emit batchFiles in this exact shape; do not hand-edit.","Validate the input object before invoking the worker."],"tags":["skill","extract-structure","input-validation","cli","json-input"],"backgroundTag":null,"analyzedSha":"32944829e7a63a9fa9c55d811d7f98a9530c6a6a","analyzedAt":"2026-08-12T10:25:44.261Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}