{"record":{"id":"bda414a353367c2e","repo":"affaan-m/ECC","slug":"failed-to-parse-label-at-filepath-error-m-bda414","errorCode":null,"errorMessage":"Failed to parse ${label} at ${filePath}: ${error.message}","messagePattern":"Failed to parse (.+?) at (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"scripts/lib/install-targets/kimi-project.js","lineNumber":15,"sourceCode":"const fs = require('fs');\nconst path = require('path');\n\nconst {\n  createInstallTargetAdapter,\n  createManagedOperation,\n  isForeignPlatformPath,\n} = require('./helpers');\n\nfunction readJsonObject(filePath, label) {\n  let parsed;\n  try {\n    parsed = JSON.parse(fs.readFileSync(filePath, 'utf8'));\n  } catch (error) {\n    throw new Error(`Failed to parse ${label} at ${filePath}: ${error.message}`);\n  }\n\n  if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {\n    throw new Error(`Invalid ${label} at ${filePath}: expected a JSON object`);\n  }\n\n  return parsed;\n}\n\nfunction createMcpMergeOperation(moduleId, repoRoot, targetRoot) {\n  if (!repoRoot) {\n    throw new Error('repoRoot is required to plan Kimi MCP configuration');\n  }\n\n  const sourceRelativePath = '.mcp.json';\n  const sourcePath = path.join(repoRoot, sourceRelativePath);\n  if (!fs.existsSync(sourcePath) || !fs.statSync(sourcePath).isFile()) {\n    return null;","sourceCodeStart":1,"sourceCodeEnd":33,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/lib/install-targets/kimi-project.js#L1-L33","documentation":"readJsonObject in the Kimi project install target reads a JSON config file (Kimi's project MCP config) and re-throws any read or parse failure with the labeled file path and underlying error message. It exists so merge operations fail with a clear, path-qualified error instead of a raw fs/JSON stack.","triggerScenarios":"createMcpMergeOperation for a Kimi project target finds a destination file that exists but is not valid JSON (comments, trailing commas, truncation) or cannot be read (ENOENT/EACCES) when it attempts to merge MCP server entries.","commonSituations":"Hand-editing the Kimi MCP config as JSONC with comments; a partial write from a crashed process; file permission changes after switching machines or users.","solutions":["Open the file at the path in the message and fix the JSON syntax error from error.message","Remove non-JSON syntax (comments, trailing commas) — Kimi project config must be plain JSON","Fix file permissions if the error indicates EACCES","If unrecoverable, back up and delete the file so the installer recreates it"],"exampleFix":"// before: .kimi/mcp.json with comment\n{ // my servers\n  \"mcpServers\": {}\n}\n// after\n{\n  \"mcpServers\": {}\n}","handlingStrategy":"try-catch","validationCode":"// Pre-flight: verify the Kimi MCP config parses before install\ntry {\n  JSON.parse(fs.readFileSync(kimiMcpPath, 'utf8'));\n} catch (e) {\n  console.error(`Fix ${kimiMcpPath} before installing: ${e.message}`);\n}","typeGuard":"function isPlainObject(v) {\n  return v !== null && typeof v === 'object' && !Array.isArray(v);\n}","tryCatchPattern":"try {\n  runInstallOperation(op);\n} catch (e) {\n  if (/Failed to parse .* at .*:/.test(e.message)) {\n    // fix the JSON at the path named in the message, then retry\n  } else throw e;\n}","preventionTips":["Keep Kimi project config files as strict plain JSON","Lint JSON config files in CI or via editor plugins before running installs","Never interrupt a running install — partial writes corrupt JSON"],"tags":["json","file-io","kimi","install-target"],"backgroundTag":"json-parse-error","analyzedSha":"8321021c54d670126ce3b2969d5deb880b4b0c2a","analyzedAt":"2026-09-16T10:08:13.343Z","contentChangedAt":"2026-09-16T10:08:13.343Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}