{"record":{"id":"0fb41fed306053d4","repo":"affaan-m/ECC","slug":"invalid-json-in-label-error-message-0fb41f","errorCode":null,"errorMessage":"Invalid JSON in ${label}: ${error.message}","messagePattern":"Invalid JSON in (.+?): (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/lib/install/config.js","lineNumber":16,"sourceCode":"'use strict';\n\nconst fs = require('fs');\nconst path = require('path');\nconst Ajv = require('ajv');\n\nconst DEFAULT_INSTALL_CONFIG = 'ecc-install.json';\nconst CONFIG_SCHEMA_PATH = path.join(__dirname, '..', '..', '..', 'schemas', 'ecc-install-config.schema.json');\n\nlet cachedValidator = null;\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 getValidator() {\n  if (cachedValidator) {\n    return cachedValidator;\n  }\n\n  const schema = readJson(CONFIG_SCHEMA_PATH, 'ecc-install-config.schema.json');\n  const ajv = new Ajv({ allErrors: true });\n  cachedValidator = ajv.compile(schema);\n  return cachedValidator;\n}\n\nfunction dedupeStrings(values) {\n  return [...new Set((Array.isArray(values) ? values : []).map(value => String(value).trim()).filter(Boolean))];\n}\n","sourceCodeStart":1,"sourceCodeEnd":34,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/scripts/lib/install/config.js#L1-L34","documentation":"Thrown by readJson in scripts/lib/install/config.js when JSON.parse fails. The helper reads either the user's install config (label = path.basename of the resolved config path) or the bundled schema at schemas/ecc-install-config.schema.json (label 'ecc-install-config.schema.json'). The original parse error is inlined.","triggerScenarios":"Calling loadInstallConfig('my-config.json') where the file is malformed JSON; or the bundled schema file is corrupt (rare — indicates a damaged ECC install).","commonSituations":"Hand-edited ecc-install.json with a trailing comma or a // comment (JSON disallows comments); UTF-8 BOM; a botched merge-conflict resolution; the schema file overwritten by a partial extraction.","solutions":["Open the file named in the message and validate with jq empty <file> or npx jsonlint <file>.","Remove any // or /* */ comments — JSON-C is not JSON.","Strip a leading BOM: sed -i '1s/^\\xEF\\xBB\\xBF//' <file>.","If the named file is the schema (ecc-install-config.schema.json), reinstall ECC — the bundled schema is corrupted."],"exampleFix":"// before (ecc-install.json)\n{\n  \"target\": \"claude\", // the target to install into\n  \"modules\": [\"core\"]\n}\n\n// after\n{\n  \"target\": \"claude\",\n  \"modules\": [\"core\"]\n}","handlingStrategy":"try-catch","validationCode":"function loadJsonStrict(p) {\n  const raw = fs.readFileSync(p, 'utf8').replace(/^\\uFEFF/, '');\n  try { return JSON.parse(raw); }\n  catch (e) { throw new Error(`${p}: ${e.message}`); }\n}\nloadJsonStrict(configPath);","typeGuard":null,"tryCatchPattern":"try {\n  loadInstallConfig(configPath, { cwd });\n} catch (err) {\n  if (/Invalid JSON in/.test(err.message)) {\n    console.error('Fix JSON syntax in', configPath, '-', err.message);\n  }\n  throw err;\n}","preventionTips":["Use a JSON-aware editor and never put // or /* */ comments in .json files.","If you want comments, name the file .jsonc and strip them before parsing.","Run jq empty on the config in CI before invoking the installer."],"tags":["json-parse","install-config"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}