{"record":{"id":"48e3b1e085270be8","repo":"affaan-m/ECC","slug":"failed-to-read-label-error-message","errorCode":null,"errorMessage":"Failed to read ${label}: ${error.message}","messagePattern":"Failed to read (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"scripts/lib/install-manifests.js","lineNumber":172,"sourceCode":"});\nconst TARGET_DEFAULT_PROFILE_IDS = Object.freeze({\n  opencode: 'opencode',\n});\nconst TARGET_DEFAULT_EXCLUSIONS = Object.freeze({\n  opencode: [\n    {\n      moduleId: 'hooks-runtime',\n      reason: 'OpenCode defaults intentionally exclude hooks-runtime until users opt in.',\n      optInCommand: './install.sh --target opencode --modules hooks-runtime',\n    },\n  ],\n});\n\nfunction readJson(filePath, label) {\n  try {\n    return JSON.parse(fs.readFileSync(filePath, 'utf8'));\n  } catch (error) {\n    throw new Error(`Failed to read ${label}: ${error.message}`);\n  }\n}\n\nfunction dedupeStrings(values) {\n  return [...new Set((Array.isArray(values) ? values : []).map(value => String(value).trim()).filter(Boolean))];\n}\n\nfunction listSkillDirectoryIds(repoRoot) {\n  const skillsRoot = path.join(repoRoot, 'skills');\n  if (!fs.existsSync(skillsRoot) || !fs.statSync(skillsRoot).isDirectory()) {\n    return [];\n  }\n\n  return fs.readdirSync(skillsRoot, { withFileTypes: true })\n    .filter(entry => entry.isDirectory())\n    .map(entry => entry.name)\n    .sort();\n}","sourceCodeStart":154,"sourceCodeEnd":190,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/lib/install-manifests.js#L154-L190","documentation":"readJson wraps fs.readFileSync + JSON.parse for manifest files (modules, profiles, components). Any read or parse failure — missing file, permissions, invalid JSON — is rethrown with the human-readable label in the message.","triggerScenarios":"Calling loadInstallManifests (via modulesData/profilesData/componentsData) when a manifest JSON file is absent, unreadable, or contains malformed JSON.","commonSituations":"Incomplete checkout or install missing manifest files; wrong repoRoot/projectRoot option pointing at the wrong directory; JSON syntax error after hand-editing a manifest; restrictive file permissions.","solutions":["Check the labeled file exists at the expected path relative to the project root","Validate the JSON parses (e.g. `node -e \"JSON.parse(require('fs').readFileSync(path,'utf8'))\"`) and fix syntax errors","Pass the correct projectRoot/homeDir options so manifests are resolved from the right directory","Fix file permissions or restore the manifest from the repo"],"exampleFix":"// before\nloadInstallManifests({ projectRoot: '/wrong/path' });\n// after\nconst fs = require('fs');\nconst p = '/repo/scripts/install-manifests/modules.json';\nif (!fs.existsSync(p)) throw new Error('restore manifests from repo');\nloadInstallManifests({ projectRoot: '/repo' });","handlingStrategy":"try-catch","validationCode":"const fs = require('fs');\nfunction manifestReadable(p) { try { JSON.parse(fs.readFileSync(p, 'utf8')); return true; } catch { return false; } }","typeGuard":null,"tryCatchPattern":"try { loadInstallManifests(opts); } catch (e) { if (String(e.message).startsWith('Failed to read')) { console.error('Check manifest path/JSON for:', e.message); process.exitCode = 1; } else throw e; }","preventionTips":["Verify projectRoot points at the repo root","Run a JSON syntax check on edited manifests before loading","Restore manifests from git if deleted or corrupted"],"tags":["json","file-read","manifest"],"backgroundTag":"file-read-failed","analyzedSha":"8321021c54d670126ce3b2969d5deb880b4b0c2a","analyzedAt":"2026-09-16T10:08:13.343Z","contentChangedAt":"2026-09-16T10:08:13.343Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}