{"record":{"id":"8d38189264457a82","repo":"affaan-m/ECC","slug":"invalid-json-in-label-error-message","errorCode":null,"errorMessage":"Invalid JSON in ${label}: ${error.message}","messagePattern":"Invalid JSON in (.+?): (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/ci/validate-install-manifests.js","lineNumber":36,"sourceCode":"const COMPONENTS_SCHEMA_PATH = path.join(REPO_ROOT, 'schemas/install-components.schema.json');\nconst CURATED_SKILLS_DIR = path.join(REPO_ROOT, 'skills');\n// Empty by default; add only curated skills that are intentionally unshipped.\nconst INTENTIONALLY_UNSHIPPED_SKILL_IDS = new Set([\n  'skill-comply', // meta/measurement dev-skill; ships committed .pyc artifacts and a nested .gitignore, revisit after packaging cleanup\n]);\nconst COMPONENT_FAMILY_PREFIXES = {\n  baseline: 'baseline:',\n  language: 'lang:',\n  framework: 'framework:',\n  capability: 'capability:',\n  locale: 'locale:',\n};\n\nfunction readJson(filePath, label) {\n  try {\n    return JSON.parse(fs.readFileSync(filePath, 'utf8'));\n  } catch (error) {\n    throw new Error(`Invalid JSON in ${label}: ${error.message}`);\n  }\n}\n\nfunction normalizeRelativePath(relativePath) {\n  return String(relativePath).replace(/\\\\/g, '/').replace(/\\/+$/, '');\n}\n\nfunction isCuratedSkillReferenced(claimedPaths, skillId) {\n  const skillRoot = `skills/${skillId}`;\n\n  for (const claimedPath of claimedPaths.keys()) {\n    if (claimedPath === skillRoot || claimedPath.startsWith(`${skillRoot}/`)) {\n      return true;\n    }\n  }\n\n  return false;\n}","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/scripts/ci/validate-install-manifests.js#L18-L54","documentation":"The readJson() helper in validate-install-manifests.js wraps JSON.parse(fs.readFileSync(...)) in a try-catch and rethrows with a labeled message. The label identifies which manifest or schema file failed (e.g. 'modules manifest', 'profiles schema'). This error fires when the file exists but contains invalid JSON syntax — trailing commas, unquoted keys, single quotes, comments, or truncated content.","triggerScenarios":"Running validate-install-manifests.js when manifests/install-modules.json, manifests/install-profiles.json, manifests/install-components.json, or their corresponding schema files contain malformed JSON. This is common after hand-editing a manifest or after a merge conflict leaves conflict markers in the file.","commonSituations":"Manual edits to install manifest JSON files that introduce syntax errors; git merge conflicts resolved incompletely leaving >>>>>>> markers; JSON5-style comments or trailing commas accidentally introduced; file truncated by an interrupted write or CI checkout issue.","solutions":["Run the JSON file through a linter or `node -e \"JSON.parse(require('fs').readFileSync('<path>','utf8'))\"` to locate the exact syntax error","Check for trailing commas, unquoted keys, single-quoted strings, or comments — none are valid JSON","If a merge conflict occurred, ensure all conflict markers (<<<<<<<, =======, >>>>>>>) are removed","Validate against the schema file to confirm structural correctness after fixing syntax"],"exampleFix":"// before — manifest contains a trailing comma\n{\n  \"modules\": [\n    { \"id\": \"foo\" },\n  ]\n}\n// after\n{\n  \"modules\": [\n    { \"id\": \"foo\" }\n  ]\n}","handlingStrategy":"try-catch","validationCode":"// Validate JSON files before running the manifest validator\nconst fs = require('fs');\nconst files = [\n  'manifests/install-modules.json',\n  'manifests/install-profiles.json',\n  'manifests/install-components.json',\n];\nfor (const file of files) {\n  try {\n    JSON.parse(fs.readFileSync(file, 'utf8'));\n    console.log(`OK: ${file}`);\n  } catch (e) {\n    console.error(`INVALID: ${file} — ${e.message}`);\n    process.exit(1);\n  }\n}","typeGuard":null,"tryCatchPattern":"// Catch the readJson error and report which file is broken\ntry {\n  validateInstallManifests();\n} catch (error) {\n  if (error.message.startsWith('Invalid JSON in')) {\n    console.error('A manifest or schema file has invalid JSON.');\n    console.error(error.message);\n    console.error('Run: npx jsonlint <file> to find the syntax error.');\n    process.exit(1);\n  }\n  throw error;\n}","preventionTips":["Use a JSON-aware editor or linter (jsonlint, prettier) when editing manifest files","Never add comments or trailing commas to .json files — JSON does not support them","After resolving git merge conflicts in JSON files, validate with `node -e \"JSON.parse(require('fs').readFileSync('file','utf8'))\"`","Run the validator locally before pushing to CI"],"tags":["json","manifest-validation","ci","schema"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}