affaan-m/ECC · error · Error
Invalid JSON in ${label}: ${error.message}
Error message
Invalid JSON in ${label}: ${error.message} What it means
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.
Source
Thrown at scripts/lib/install/config.js:16
'use strict';
const fs = require('fs');
const path = require('path');
const Ajv = require('ajv');
const DEFAULT_INSTALL_CONFIG = 'ecc-install.json';
const CONFIG_SCHEMA_PATH = path.join(__dirname, '..', '..', '..', 'schemas', 'ecc-install-config.schema.json');
let cachedValidator = null;
function readJson(filePath, label) {
try {
return JSON.parse(fs.readFileSync(filePath, 'utf8'));
} catch (error) {
throw new Error(`Invalid JSON in ${label}: ${error.message}`);
}
}
function getValidator() {
if (cachedValidator) {
return cachedValidator;
}
const schema = readJson(CONFIG_SCHEMA_PATH, 'ecc-install-config.schema.json');
const ajv = new Ajv({ allErrors: true });
cachedValidator = ajv.compile(schema);
return cachedValidator;
}
function dedupeStrings(values) {
return [...new Set((Array.isArray(values) ? values : []).map(value => String(value).trim()).filter(Boolean))];
}
View on GitHub (pinned to 01e15490f0)
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.
Example fix
// before (ecc-install.json)
{
"target": "claude", // the target to install into
"modules": ["core"]
}
// after
{
"target": "claude",
"modules": ["core"]
} Defensive patterns
Strategy: try-catch
Validate before calling
function loadJsonStrict(p) {
const raw = fs.readFileSync(p, 'utf8').replace(/^\uFEFF/, '');
try { return JSON.parse(raw); }
catch (e) { throw new Error(`${p}: ${e.message}`); }
}
loadJsonStrict(configPath); Try / catch
try {
loadInstallConfig(configPath, { cwd });
} catch (err) {
if (/Invalid JSON in/.test(err.message)) {
console.error('Fix JSON syntax in', configPath, '-', err.message);
}
throw err;
} Prevention
- 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.
When it happens
Trigger: Calling loadInstallConfig('my-config.json') where the file is malformed JSON; or the bundled schema file is corrupt (rare — indicates a damaged ECC install).
Common situations: 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.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- Failed to parse ${label} at ${filePath}: ${error.message}
- Failed to parse ${label} at ${filePath}: ${error.message}
- An install config path is required
- Install config not found: ${resolvedPath}
- Invalid install config ${resolvedPath}: ${formatValidationEr
AI-assisted analysis of affaan-m/ECC@01e15490f0 (2026-08-13).
Data as JSON: /api/errors/0fb41fed306053d4.
Report an issue: GitHub.