{"record":{"id":"4427bbe3af5f54b4","repo":"affaan-m/ECC","slug":"install-module-moduleid-has-invalid-targets-ex","errorCode":null,"errorMessage":"Install module ${moduleId} has invalid targets; expected an array of supported target ids","messagePattern":"Install module (.+?) has invalid targets; expected an array of supported target ids","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"scripts/lib/install-manifests.js","lineNumber":251,"sourceCode":"    || options[key] === null\n    || options[key] === undefined\n  ) {\n    return null;\n  }\n\n  if (typeof options[key] !== 'string' || options[key].trim() === '') {\n    throw new Error(`${key} must be a non-empty string when provided`);\n  }\n\n  return options[key];\n}\n\nfunction readModuleTargetsOrThrow(module) {\n  const moduleId = module && module.id ? module.id : '<unknown>';\n  const targets = module && module.targets;\n\n  if (!Array.isArray(targets)) {\n    throw new Error(`Install module ${moduleId} has invalid targets; expected an array of supported target ids`);\n  }\n\n  const normalizedTargets = targets.map(target => (\n    typeof target === 'string' ? target.trim() : ''\n  ));\n\n  if (normalizedTargets.some(target => target.length === 0)) {\n    throw new Error(`Install module ${moduleId} has invalid targets; expected an array of supported target ids`);\n  }\n\n  const unsupportedTargets = normalizedTargets.filter(target => !SUPPORTED_INSTALL_TARGETS.includes(target));\n  if (unsupportedTargets.length > 0) {\n    throw new Error(\n      `Install module ${moduleId} has unsupported targets: ${unsupportedTargets.join(', ')}`\n    );\n  }\n\n  return normalizedTargets;","sourceCodeStart":233,"sourceCodeEnd":269,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/lib/install-manifests.js#L233-L269","documentation":"readModuleTargetsOrThrow throws when an install module's `targets` property is not an array. The faulting input is the module object in the install-modules manifest; the schema expects an array of supported target ids (e.g. 'claude', 'codex', 'cursor').","triggerScenarios":"Loading install manifests where a module definition has targets missing, set to a string/object/null, or an array containing unsupported non-string entries that fail normalization.","commonSituations":"Hand-editing a module manifest and dropping or mistyping `targets`; adding a new module without declaring targets; schema change where targets became an object map.","solutions":["Fix the module entry so targets is an array of valid target ids.","Validate manifests against schemas/install-modules.schema.json before loading.","Regenerate the manifest if it is produced by tooling."],"exampleFix":"// before\n{ \"id\": \"agents\", \"targets\": \"claude\" }\n// after\n{ \"id\": \"agents\", \"targets\": [\"claude\", \"codex\", \"cursor\"] }","handlingStrategy":"validation","validationCode":"const TARGETS = new Set(['claude','codex','cursor']);\nfunction validateModule(m) { if (!Array.isArray(m.targets) || m.targets.some(t => !TARGETS.has(String(t).trim()))) throw new Error(`module ${m.id} has invalid targets`); }","typeGuard":"const hasValidTargets = (m) => Array.isArray(m?.targets) && m.targets.every(t => typeof t === 'string' && t.trim());","tryCatchPattern":"try { loadInstallManifests(opts); } catch (e) { if (e.message.includes('has invalid targets')) { console.error('Fix the module targets array in the manifest:', e.message); } else throw e; }","preventionTips":["Validate module manifests against the schema before loading","Always declare targets as a string array when adding modules","Lint manifests in CI to catch schema drift"],"tags":["manifest","validation","config"],"backgroundTag":"invalid-config-value","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"}