{"record":{"id":"93a38b81af1a93f2","repo":"affaan-m/ECC","slug":"harness-capability-catalog-contains-duplicate-inst","errorCode":null,"errorMessage":"Harness capability catalog contains duplicate install target ids","messagePattern":"Harness capability catalog contains duplicate install target ids","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/lib/harness-capabilities.js","lineNumber":264,"sourceCode":"  }\n}\n\nfunction expectedRootForAdapter(adapter) {\n  const homeDir = path.resolve('/__ecc_catalog_home__');\n  const projectRoot = path.resolve('/__ecc_catalog_project__');\n  const absoluteRoot = adapter.resolveRoot({ homeDir, projectRoot });\n  const baseRoot = adapter.kind === 'home' ? homeDir : projectRoot;\n  const prefix = adapter.kind === 'home' ? '~/' : './';\n  return `${prefix}${path.relative(baseRoot, absoluteRoot).replace(/\\\\/g, '/')}`;\n}\n\nfunction validateCatalog() {\n  const adapters = listInstallTargetAdapters();\n  const adapterByTarget = new Map(adapters.map(adapter => [adapter.target, adapter]));\n  const catalogTargetIds = HARNESS_CAPABILITIES.flatMap(harness => harness.targetIds);\n\n  if (new Set(catalogTargetIds).size !== catalogTargetIds.length) {\n    throw new Error('Harness capability catalog contains duplicate install target ids');\n  }\n\n  const supported = [...SUPPORTED_INSTALL_TARGETS].sort();\n  const registered = adapters.map(adapter => adapter.target).sort();\n  const catalogued = [...catalogTargetIds].sort();\n  if (\n    JSON.stringify(catalogued) !== JSON.stringify(supported)\n    || JSON.stringify(catalogued) !== JSON.stringify(registered)\n  ) {\n    throw new Error('Harness capability catalog is out of sync with install targets');\n  }\n\n  for (const harness of HARNESS_CAPABILITIES) {\n    for (const declaredScope of harness.scopes) {\n      const adapter = adapterByTarget.get(declaredScope.targetId);\n      if (!adapter || expectedRootForAdapter(adapter) !== declaredScope.root) {\n        throw new Error(\n          `Harness capability root is out of sync for target ${declaredScope.targetId}`","sourceCodeStart":246,"sourceCodeEnd":282,"githubUrl":"https://github.com/affaan-m/ECC/blob/d8409a4b0813771235555e32e3d8046a73988bfa/scripts/lib/harness-capabilities.js#L246-L282","documentation":"harness-capabilities.js runs validateCatalog() at require() time. This check flattens every harness entry's targetIds and throws if any install-target id appears more than once across the catalog — each target must be owned by exactly one harness entry. A throw here crashes on module load, so every consumer of the file fails immediately.","triggerScenarios":"A contributor edits HARNESS_CAPABILITIES and adds a targetId (e.g. 'cursor') to a second harness entry that already lists it elsewhere. Any `require('./harness-capabilities.js')` — including unrelated CLI entry points — then throws during startup.","commonSituations":"Copy-pasting an existing harness entry as a template and forgetting to replace its targetIds; a git merge that keeps the same target in two entries; refactoring that moves a target between harnesses without deleting the old reference.","solutions":["Search HARNESS_CAPABILITIES for the duplicated target id and remove it from all but one harness's targetIds array","Verify the fix loads: `node -e \"require('./scripts/lib/harness-capabilities.js')\"` must exit silently","Add/keep a unit test asserting Set(targetIds).size === targetIds.length so CI catches it before review","When moving a target between harnesses, delete the old reference in the same commit"],"exampleFix":"// before\n{ id: 'vscode-family', targetIds: ['cursor', 'codebuddy'] },\n{ id: 'other', targetIds: ['cursor', 'qwen'] },\n\n// after\n{ id: 'vscode-family', targetIds: ['cursor', 'codebuddy'] },\n{ id: 'other', targetIds: ['qwen'] },","handlingStrategy":"validation","validationCode":"// CI guard: catalog target ids must be unique across harnesses\nconst { HARNESS_CAPABILITIES } = require('./scripts/lib/harness-capabilities.js');\nconst ids = HARNESS_CAPABILITIES.flatMap(h => h.targetIds);\nif (new Set(ids).size !== ids.length) {\n  const dup = ids.find((id, i) => ids.indexOf(id) !== i);\n  throw new Error(`Duplicate targetId in catalog: ${dup}`);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run `node -e \"require('./scripts/lib/harness-capabilities.js')\"` in CI to catch load-time invariant failures","When moving a target between harnesses, delete the old targetIds entry in the same commit","Review catalog diffs for copy-pasted targetIds from template entries"],"tags":["internal-invariant","catalog","duplicates","module-load","developer-error"],"backgroundTag":"duplicate-catalog-entry","analyzedSha":"d8409a4b0813771235555e32e3d8046a73988bfa","analyzedAt":"2026-08-26T12:15:34.022Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}