affaan-m/ECC · error · Error
Failed to parse ${label} at ${filePath}: ${error.message}
Error message
Failed to parse ${label} at ${filePath}: ${error.message} What it means
Thrown by readJsonObject() in scripts/lib/install-executor.js when a manifest or scaffold JSON file cannot be read or parsed. The label argument tells you which artifact failed (e.g. 'manifest', 'scaffold') and the message echoes the underlying parse error.
Source
Thrown at scripts/lib/install-executor.js:198
operations.push(
buildCopyFileOperation({
moduleId: options.moduleId,
sourcePath,
sourceRelativePath: options.sourceRelativePath,
destinationPath: options.destinationPath,
strategy: options.strategy || 'preserve-relative-path'
})
);
return true;
}
function readJsonObject(filePath, label) {
let parsed;
try {
parsed = JSON.parse(fs.readFileSync(filePath, 'utf8'));
} catch (error) {
throw new Error(`Failed to parse ${label} at ${filePath}: ${error.message}`);
}
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
throw new Error(`Invalid ${label} at ${filePath}: expected a JSON object`);
}
return parsed;
}
function addCursorAgentDataScaffoldOperations(operations, options) {
const scaffoldRoot = path.join(options.sourceRoot, 'scaffolds', 'cursor');
if (!fs.existsSync(scaffoldRoot)) {
return;
}
addFileCopyOperation(operations, {
moduleId: options.moduleId,
sourceRoot: options.sourceRoot,View on GitHub (pinned to 01e15490f0)
Solutions
- Open the file at the path in the message and run it through a JSON validator.
- Regenerate from source: git checkout -- <filePath> or re-run npm run catalog:sync / npm run command-registry:write as appropriate.
- Confirm the file exists and is readable: ls -l <filePath>.
- Resolve git conflict markers (<<<<<<<, =======, >>>>>>>) which are not valid JSON.
Example fix
// before (manifests/install-modules.json contains a trailing comma)
{
"version": 1,
"modules": [],
}
// after
{
"version": 1,
"modules": []
} Defensive patterns
Strategy: try-catch
Validate before calling
const fs = require('fs');
function isReadableJsonObject(p) {
try {
const v = JSON.parse(fs.readFileSync(p, 'utf8'));
return v && typeof v === 'object' && !Array.isArray(v);
} catch { return false; }
}
if (!isReadableJsonObject(filePath)) {
throw new Error(`${filePath} is missing or invalid JSON`);
} Try / catch
let parsed;
try {
parsed = readJsonObject(filePath, label);
} catch (err) {
if (/Failed to parse/.test(err.message)) {
throw new Error(`Manifest corrupt: ${err.message}. Run npm run catalog:sync.`);
}
throw err;
} Prevention
- Add a CI step that JSON.parse-checks every manifest and scaffold file.
- Use git checkout -- to restore a generated file rather than editing by hand.
- Run npm run catalog:sync / npm run command-registry:write after changing catalog sources.
When it happens
Trigger: readJsonObject(filePath, label) where fs.readFileSync throws (ENOENT, EACCES) or JSON.parse throws (syntax error). Called when install-executor reads manifests/install-modules.json, manifests/install-components.json, scaffolds/*/ecc-agent-data.json, etc.
Common situations: A generated manifest was hand-edited and broke; file deleted mid-install; merge conflict markers left in JSON; BOM or CRLF corruption; partial git checkout left a truncated file.
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
- Invalid ${label} at ${filePath}: expected a JSON object
- Invalid ${label}: ${error.message}
- Failed to read ${label}: ${error.message}
- gh ${args.join(' ')} returned invalid JSON: ${error.message}
- Malformed coordination JSON in body: ${error.message} — raw:
AI-assisted analysis of affaan-m/ECC@01e15490f0 (2026-08-13).
Data as JSON: /api/errors/1b388352e06839b5.
Report an issue: GitHub.