{"record":{"id":"ee156496952b0621","repo":"affaan-m/ECC","slug":"label-is-invalid-at-filepath-error-messag","errorCode":null,"errorMessage":"${label} is invalid at ${filePath}: ${error.message}","messagePattern":"(.+?) is invalid at (.+?): (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/lib/install/inventory.js","lineNumber":36,"sourceCode":"    || os.homedir();\n  const configDir = options.configDir\n    || process.env.CLAUDE_CONFIG_DIR\n    || path.join(homeDir, '.claude');\n  const projectRoot = options.projectRoot || process.cwd();\n\n  return {\n    homeDir: path.resolve(homeDir),\n    configDir: path.resolve(configDir),\n    projectRoot: path.resolve(projectRoot),\n  };\n}\n\nfunction readJsonObject(filePath, label) {\n  let value;\n  try {\n    value = JSON.parse(fs.readFileSync(filePath, 'utf8'));\n  } catch (error) {\n    throw new Error(`${label} is invalid at ${filePath}: ${error.message}`);\n  }\n  if (!value || typeof value !== 'object' || Array.isArray(value)) {\n    throw new Error(`${label} is invalid at ${filePath}: expected a JSON object`);\n  }\n  return value;\n}\n\nfunction findManualClaudePlugin(options = {}) {\n  const { configDir } = resolveClaudePaths(options);\n  const pluginsDir = path.join(configDir, 'plugins');\n  const candidates = [\n    ['ecc', '.claude-plugin', 'plugin.json'],\n    ['ecc', 'plugin.json'],\n    ['ecc@ecc', '.claude-plugin', 'plugin.json'],\n    ['ecc@ecc', 'plugin.json'],\n    ['everything-claude-code', '.claude-plugin', 'plugin.json'],\n    ['everything-claude-code', 'plugin.json'],\n  ];","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/scripts/lib/install/inventory.js#L18-L54","documentation":"Thrown by readJsonObject in scripts/lib/install/inventory.js when JSON.parse fails. The helper is called in findManagedClaudeInstalls with label 'Managed Claude install-state' on either <configDir>/ecc/install-state.json or <projectRoot>/.claude/ecc/install-state.json. The original parse error is inlined.","triggerScenarios":"Running the inventory/repair flow when an existing ECC install-state.json is corrupt JSON — usually from an interrupted install, manual edit, or disk issue.","commonSituations":"A previous install was killed mid-write; a tool manually edited install-state.json; disk corruption; a partial state left by a crashed upgrade.","solutions":["Open the named install-state.json and run jq empty <file> to find the parse error.","If unrecoverable, back it up and delete it — ECC will treat the install as unmanaged and you can reinstall cleanly.","Re-run the ECC inventory command to confirm the state is regenerated.","Audit why the file became corrupt (interrupted process, concurrent writers) before retrying."],"exampleFix":"# before\n$ jq empty ~/.claude/ecc/install-state.json\nparse error: ...\n\n# after\nmv ~/.claude/ecc/install-state.json ~/.claude/ecc/install-state.json.bak\n# re-run the install / inventory command","handlingStrategy":"try-catch","validationCode":"function safeReadState(p) {\n  try { return JSON.parse(fs.readFileSync(p, 'utf8')); }\n  catch (e) { return null; }\n}\nconst state = safeReadState(statePath);\nif (!state) {\n  console.warn(`Unreadable state at ${statePath} — ECC will treat the install as unmanaged.`);\n}","typeGuard":"function isJsonObject(v) {\n  return v !== null && typeof v === 'object' && !Array.isArray(v);\n}","tryCatchPattern":"try {\n  findManagedClaudeInstalls();\n} catch (err) {\n  if (/install-state is invalid at/.test(err.message)) {\n    console.error('Corrupt install-state — back up and remove, then reinstall.');\n  }\n  throw err;\n}","preventionTips":["Never hand-edit install-state.json.","If an install is interrupted, remove the partial state file before retrying.","Run the inventory command after every ECC upgrade to detect state drift early."],"tags":["json-parse","install-state","inventory"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}