{"record":{"id":"1b388352e06839b5","repo":"affaan-m/ECC","slug":"failed-to-parse-label-at-filepath-error-m","errorCode":null,"errorMessage":"Failed to parse ${label} at ${filePath}: ${error.message}","messagePattern":"Failed to parse (.+?) at (.+?): (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/lib/install-executor.js","lineNumber":198,"sourceCode":"  operations.push(\n    buildCopyFileOperation({\n      moduleId: options.moduleId,\n      sourcePath,\n      sourceRelativePath: options.sourceRelativePath,\n      destinationPath: options.destinationPath,\n      strategy: options.strategy || 'preserve-relative-path'\n    })\n  );\n\n  return true;\n}\n\nfunction readJsonObject(filePath, label) {\n  let parsed;\n  try {\n    parsed = JSON.parse(fs.readFileSync(filePath, 'utf8'));\n  } catch (error) {\n    throw new Error(`Failed to parse ${label} at ${filePath}: ${error.message}`);\n  }\n\n  if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {\n    throw new Error(`Invalid ${label} at ${filePath}: expected a JSON object`);\n  }\n\n  return parsed;\n}\n\nfunction addCursorAgentDataScaffoldOperations(operations, options) {\n  const scaffoldRoot = path.join(options.sourceRoot, 'scaffolds', 'cursor');\n  if (!fs.existsSync(scaffoldRoot)) {\n    return;\n  }\n\n  addFileCopyOperation(operations, {\n    moduleId: options.moduleId,\n    sourceRoot: options.sourceRoot,","sourceCodeStart":180,"sourceCodeEnd":216,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/scripts/lib/install-executor.js#L180-L216","documentation":"Thrown by readJsonObject() in scripts/lib/install-executor.js when a manifest or scaffold JSON file cannot be read or parsed. The label argument tells you which artifact failed (e.g. 'manifest', 'scaffold') and the message echoes the underlying parse error.","triggerScenarios":"readJsonObject(filePath, label) where fs.readFileSync throws (ENOENT, EACCES) or JSON.parse throws (syntax error). Called when install-executor reads manifests/install-modules.json, manifests/install-components.json, scaffolds/*/ecc-agent-data.json, etc.","commonSituations":"A generated manifest was hand-edited and broke; file deleted mid-install; merge conflict markers left in JSON; BOM or CRLF corruption; partial git checkout left a truncated file.","solutions":["Open the file at the path in the message and run it through a JSON validator.","Regenerate from source: git checkout -- <filePath> or re-run npm run catalog:sync / npm run command-registry:write as appropriate.","Confirm the file exists and is readable: ls -l <filePath>.","Resolve git conflict markers (<<<<<<<, =======, >>>>>>>) which are not valid JSON."],"exampleFix":"// before (manifests/install-modules.json contains a trailing comma)\n{\n  \"version\": 1,\n  \"modules\": [],\n}\n\n// after\n{\n  \"version\": 1,\n  \"modules\": []\n}","handlingStrategy":"try-catch","validationCode":"const fs = require('fs');\nfunction isReadableJsonObject(p) {\n  try {\n    const v = JSON.parse(fs.readFileSync(p, 'utf8'));\n    return v && typeof v === 'object' && !Array.isArray(v);\n  } catch { return false; }\n}\nif (!isReadableJsonObject(filePath)) {\n  throw new Error(`${filePath} is missing or invalid JSON`);\n}","typeGuard":null,"tryCatchPattern":"let parsed;\ntry {\n  parsed = readJsonObject(filePath, label);\n} catch (err) {\n  if (/Failed to parse/.test(err.message)) {\n    throw new Error(`Manifest corrupt: ${err.message}. Run npm run catalog:sync.`);\n  }\n  throw err;\n}","preventionTips":["Add a CI step that JSON.parse-checks every manifest and scaffold file.","Use git checkout -- to restore a generated file rather than editing by hand.","Run npm run catalog:sync / npm run command-registry:write after changing catalog sources."],"tags":["json","parsing","install","manifest"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}