{"record":{"id":"91aefdac8d4ac9ba","repo":"affaan-m/ECC","slug":"invalid-claude-scope-claudescope","errorCode":null,"errorMessage":"Invalid Claude scope: ${claudeScope}","messagePattern":"Invalid Claude scope: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/lib/multi-harness-setup.js","lineNumber":39,"sourceCode":"  const harnesses = normalizeHarnessSelection(input.harnesses || []);\n  if (harnesses.length === 0) {\n    throw new Error('Choose at least one guided harness: Claude, Codex, or Kimi.');\n  }\n\n  const includesClaude = harnesses.includes('claude');\n  const includesKimi = harnesses.includes('kimi');\n  if (!includesClaude && (input.claudeScope !== undefined || input.claudeHooks !== undefined)) {\n    throw new Error('Claude scope and hook options require Claude to be selected.');\n  }\n  if (!includesKimi && input.profile !== undefined) {\n    throw new Error('The managed install profile requires Kimi to be selected.');\n  }\n\n  const claudeScope = includesClaude ? (input.claudeScope || 'user') : undefined;\n  const claudeHooks = includesClaude ? (input.claudeHooks || 'standard') : undefined;\n  const profile = includesKimi ? (input.profile || 'core') : undefined;\n  if (claudeScope && !VALID_CLAUDE_SCOPES.has(claudeScope)) {\n    throw new Error(`Invalid Claude scope: ${claudeScope}`);\n  }\n  if (claudeHooks && !VALID_CLAUDE_HOOKS.has(claudeHooks)) {\n    throw new Error(`Invalid Claude hooks preference: ${claudeHooks}`);\n  }\n  if (profile && !VALID_PROFILES.has(profile)) {\n    throw new Error(`Invalid Kimi install profile: ${profile}`);\n  }\n\n  return {\n    harnesses,\n    ...(claudeHooks ? { claudeHooks } : {}),\n    ...(claudeScope ? { claudeScope } : {}),\n    dryRun: Boolean(input.dryRun),\n    json: Boolean(input.json),\n    ...(profile ? { profile } : {}),\n    yes: Boolean(input.yes),\n  };\n}","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/lib/multi-harness-setup.js#L21-L57","documentation":"normalizeGuidedInstallRequest validates the resolved claudeScope (defaulting to 'user' when Claude is selected and no value given) against the VALID_CLAUDE_SCOPES set. An unrecognized scope string throws this error with the offending value interpolated. It is a whitelist enum check on user-supplied configuration.","triggerScenarios":"Calling the guided install request API with input.claudeScope set to a string not in VALID_CLAUDE_SCOPES (e.g. a typo like 'global', 'repo', or 'workspace' instead of a valid value such as 'user' or 'project').","commonSituations":"Typo in a script or CI config; copying a scope name from another tool with different vocabulary; casing mismatch ('Project' vs 'project').","solutions":["Use one of the valid Claude scopes (check VALID_CLAUDE_SCOPES in scripts/lib/multi-harness-setup.js, e.g. 'user' or 'project')","Omit claudeScope entirely to get the default 'user' scope","Trim/lowercase the value before passing it if it comes from user input"],"exampleFix":"// before\nrunSetup({ harnesses: ['claude'], claudeScope: 'global' })\n// after\nrunSetup({ harnesses: ['claude'], claudeScope: 'user' })","handlingStrategy":"validation","validationCode":"const VALID_SCOPES = ['user', 'project'] // confirm against VALID_CLAUDE_SCOPES in the library\nif (input.claudeScope !== undefined && !VALID_SCOPES.includes(input.claudeScope)) {\n  throw new Error(`claudeScope must be one of: ${VALID_SCOPES.join(', ')}`)\n}","typeGuard":"const isValidScope = (s) => typeof s === 'string' && ['user', 'project'].includes(s)","tryCatchPattern":"try {\n  return normalizeGuidedInstallRequest(input)\n} catch (err) {\n  if (err.message.startsWith('Invalid Claude scope:')) {\n    console.error(err.message, '— valid scopes:', [...VALID_CLAUDE_SCOPES])\n    return normalizeGuidedInstallRequest({ ...input, claudeScope: undefined })\n  }\n  throw err\n}","preventionTips":["Import/derive valid values from the library's exported sets instead of hardcoding strings","Use CLI choice lists restricted to valid scopes","Normalize case/whitespace before passing user input"],"tags":["validation","enum","config"],"backgroundTag":"invalid-enum-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"}