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 the cursor-project adapter when reading a source file intended for a 'merge-json' operation. JSON.parse failed on the file at filePath. The label is typically the sourceRelativePath so the message identifies which module's source asset is broken.

Source

Thrown at scripts/lib/install-targets/cursor-project.js:28

  isForeignPlatformPath,
} = require('./helpers');

function toCursorRuleFileName(fileName, sourceRelativeFile) {
  if (path.basename(sourceRelativeFile).toLowerCase() === 'readme.md') {
    return null;
  }

  return fileName.endsWith('.md')
    ? `${fileName.slice(0, -3)}.mdc`
    : fileName;
}

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 createJsonMergeOperation({ moduleId, repoRoot, sourceRelativePath, destinationPath }) {
  const sourcePath = path.join(repoRoot, sourceRelativePath);
  if (!fs.existsSync(sourcePath) || !fs.statSync(sourcePath).isFile()) {
    return null;
  }

  return createManagedOperation({
    kind: 'merge-json',
    moduleId,

View on GitHub (pinned to 01e15490f0)

Solutions

  1. Open the file at filePath and run a JSON linter — fix trailing commas / comments / unquoted keys.
  2. If the file should allow comments, pre-strip them before pointing the merge operation at it.
  3. Remove the offending source asset from the module's manifest if it is not needed.
  4. Re-clone the repo or git checkout HEAD -- on the broken file.

Example fix

// before — source file contains a comment
// settings.json
{ "foo": 1 /* default */ }
// after
{ "foo": 1 }
Defensive patterns

Strategy: try-catch

Validate before calling

let text;
try { text = fs.readFileSync(filePath, 'utf8'); }
catch (e) { throw new Error(`Cannot read ${filePath}: ${e.message}`); }
try { JSON.parse(text); } catch (e) {
  throw new Error(`${filePath} is not valid JSON — fix or remove the merge source.`);
}

Try / catch

try {
  return readJsonObject(filePath, label);
} catch (err) {
  if (/^Failed to parse/.test(err.message)) {
    // log and skip this merge operation
    return null;
  }
  throw err;
}

Prevention

When it happens

Trigger: A module ships a source .json for merge into .cursor/ but the file is not valid JSON (trailing comma, unquoted keys, comments, BOM, truncation). The adapter only triggers this when createJsonMergeOperation chose that file.

Common situations: A source JSONC file (with comments) was used where strict JSON is required; an editor inserted a BOM; a copy was truncated mid-transfer; line-ending corruption.

Understand the failure class

Related errors


AI-assisted analysis of affaan-m/ECC@01e15490f0 (2026-08-13). Data as JSON: /api/errors/83c1963c5d929ed3. Report an issue: GitHub.