{"record":{"id":"068c8eceb532968a","repo":"Egonex-AI/Understand-Anything","slug":"invalid-input-requires-projectroot-string-sou","errorCode":null,"errorMessage":"Invalid input: requires { projectRoot: string, sourceFilePaths: string[], gitCommitHash: string }","messagePattern":"Invalid input: requires (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"understand-anything-plugin/skills/understand/build-fingerprints.mjs","lineNumber":70,"sourceCode":"  builtinLanguageConfigs,\n  registerAllParsers,\n  buildFingerprintStore,\n  saveFingerprints,\n} = core;\n\nasync function main() {\n  const [, , inputPath] = process.argv;\n  if (!inputPath) {\n    process.stderr.write('Usage: node build-fingerprints.mjs <input.json>\\n');\n    process.exit(1);\n  }\n\n  const { projectRoot, sourceFilePaths, gitCommitHash } = JSON.parse(\n    readFileSync(inputPath, 'utf-8'),\n  );\n\n  if (!projectRoot || !Array.isArray(sourceFilePaths) || typeof gitCommitHash !== 'string') {\n    throw new Error(\n      'Invalid input: requires { projectRoot: string, sourceFilePaths: string[], gitCommitHash: string }',\n    );\n  }\n\n  // Create tree-sitter plugin with all configs that have WASM grammars,\n  // mirroring extract-structure.mjs so the baseline matches the comparison\n  // logic used during auto-updates.\n  const tsConfigs = builtinLanguageConfigs.filter((c) => c.treeSitter);\n  const tsPlugin = new TreeSitterPlugin(tsConfigs);\n  await tsPlugin.init();\n\n  const registry = new PluginRegistry();\n  registry.register(tsPlugin);\n  registerAllParsers(registry);\n\n  const store = buildFingerprintStore(projectRoot, sourceFilePaths, registry, gitCommitHash);\n  saveFingerprints(projectRoot, store);\n","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/Egonex-AI/Understand-Anything/blob/32944829e7a63a9fa9c55d811d7f98a9530c6a6a/understand-anything-plugin/skills/understand/build-fingerprints.mjs#L52-L88","documentation":"Thrown by build-fingerprints.mjs main() after JSON.parse-ing its input file. It validates that the input object has projectRoot (truthy), sourceFilePaths (an Array), and gitCommitHash (typeof string). Missing or wrong-typed any of the three aborts before constructing the tree-sitter plugin, since fingerprints are meaningless without a known commit and file set.","triggerScenarios":"process.argv[3] (inputPath) is missing — but that hits the earlier usage/exit(1) branch. This specific throw fires when the JSON file parsed fine but lacks projectRoot, has sourceFilePaths that is not an array (e.g. an object or string), or gitCommitHash is not a string (e.g. undefined, number).","commonSituations":"The caller (project-scanner agent / fingerprint driver) wrote an input JSON with a field typo (sourceFilePaths vs filePaths, commit vs gitCommitHash). sourceFilePaths was passed as a single string rather than an array. The repo has no git commit (detached/empty) so gitCommitHash came back undefined. An old input format predating the schema.","solutions":["Inspect the input JSON at the inputPath argument: confirm it has projectRoot (non-empty string), sourceFilePaths (array of strings), and gitCommitHash (string).","If gitCommitHash is missing, ensure the repo is a git checkout with at least one commit before regenerating the input.","Update the producer (the agent/script that writes this input) to use the exact field names projectRoot, sourceFilePaths, gitCommitHash.","Wrap a single file in an array: pass [\"./src/a.ts\"] not \"./src/a.ts\" for sourceFilePaths."],"exampleFix":"// before — wrong field names / scalar instead of array\n{ \"root\": \"./repo\", \"files\": \"./src/a.ts\", \"commit\": \"abc123\" }\n\n// after — exact schema\n{ \"projectRoot\": \"./repo\", \"sourceFilePaths\": [\"./src/a.ts\"], \"gitCommitHash\": \"abc123\" }","handlingStrategy":"validation","validationCode":"import { readFileSync } from 'node:fs';\nfunction readFingerprintInput(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.sourceFilePaths)) throw new Error('sourceFilePaths must be an array');\n  if (typeof raw.gitCommitHash !== 'string') throw new Error('gitCommitHash must be a string');\n  return raw;\n}","typeGuard":"function isFingerprintInput(v) {\n  return v !== null && typeof v === 'object'\n    && typeof v.projectRoot === 'string' && v.projectRoot.length > 0\n    && Array.isArray(v.sourceFilePaths)\n    && v.sourceFilePaths.every((f) => typeof f === 'string')\n    && typeof v.gitCommitHash === 'string';\n}","tryCatchPattern":"try {\n  const input = readFingerprintInput(inputPath);\n  // ... proceed\n} catch (e) {\n  process.stderr.write(`build-fingerprints input invalid: ${e.message}\\n`);\n  process.exit(1);\n}","preventionTips":["Producers must emit exactly projectRoot, sourceFilePaths (array), gitCommitHash (string).","Ensure the repo has at least one git commit before fingerprinting.","Wrap single files in an array rather than passing a scalar."],"tags":["skill","fingerprint","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"}