{"record":{"id":"f8fa8c5b946d5978","repo":"affaan-m/ECC","slug":"invalid-scope","errorCode":"INVALID_SCOPE","errorMessage":"Scope migration requires --scope user, project, or local.","messagePattern":"Scope migration requires --scope user, project, or local\\.","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"scripts/lib/claude-scope-migration.js","lineNumber":248,"sourceCode":"      }\n    );\n  }\n}\n\nfunction verifyFinalState(run, paths, destinationScope) {\n  const plugins = readPluginInventory(run, paths.projectRoot, 'final-verification');\n  return validateExpectedScopes(plugins, [destinationScope], {\n    code: 'FINAL_VERIFICATION_FAILED',\n    destinationScope,\n    message: `Could not verify destination-only ${CURRENT_PLUGIN_ID} state after source cleanup.`,\n    phase: 'final-verification',\n    recovery: recoveryCommands(null, destinationScope),\n  });\n}\n\nfunction migrateClaudePluginScope(options = {}, dependencies = {}) {\n  if (!VALID_SCOPES.has(options.scope)) {\n    throw migrationError(\n      'INVALID_SCOPE',\n      'Scope migration requires --scope user, project, or local.'\n    );\n  }\n  if (options.hooks !== undefined && !VALID_HOOK_MODES.has(options.hooks)) {\n    throw migrationError('INVALID_HOOK_MODE', `Invalid hook mode: ${options.hooks}`);\n  }\n\n  const paths = resolveClaudePaths(options);\n  const settingsPath = path.join(paths.configDir, 'settings.json');\n  const settings = readSettings(settingsPath);\n  assertSafeLocalInventory(paths);\n  assertGitAvailable(\n    { cwd: paths.projectRoot },\n    { spawnSync: dependencies.spawnSync }\n  );\n  const providerRun = dependencies.runClaude || runClaude;\n  const run = options.dryRun","sourceCodeStart":230,"sourceCodeEnd":266,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/lib/claude-scope-migration.js#L230-L266","documentation":"ClaudeSetupError with code INVALID_SCOPE thrown at the entry of migrateClaudePluginScope in scripts/lib/claude-scope-migration.js:248. The destination scope is validated against the VALID_SCOPES set ('user', 'project', 'local') before any migration work begins. Any other value — misspelled scopes, empty values, or unsupported targets like 'global' — is rejected immediately with this message so invalid input never reaches Claude CLI calls.","triggerScenarios":"Invoking the scope migration API or CLI with `options.scope` set to anything other than exactly 'user', 'project', or 'local' — e.g. `--scope global`, `--scope User` (case-sensitive), `--scope ''`, or omitting the scope entirely (undefined fails the Set check).","commonSituations":"Typo in a CLI flag value; assuming a 'global' or 'workspace' scope exists; shell variable expansion producing an empty --scope value; case-sensitivity mistakes ('User' vs 'user').","solutions":["Use one of the three supported values: `--scope user`, `--scope project`, or `--scope local`.","If the value comes from a variable, echo it first to confirm it is non-empty and correctly spelled.","Check case — the validation is exact-match against lowercase scope names.","If calling the JS API directly, pass `{ scope: 'project' }` (etc.) in options rather than a nested or renamed key."],"exampleFix":"// before\n// ecc migrate-scope --scope global\n\n// after\n// ecc migrate-scope --scope user","handlingStrategy":"validation","validationCode":"const VALID_SCOPES = new Set(['user', 'project', 'local']);\nif (!VALID_SCOPES.has(scope)) {\n  throw new Error(`Scope migration requires --scope user, project, or local (got: ${scope})`);\n}","typeGuard":"function isValidScope(v) { return typeof v === 'string' && ['user', 'project', 'local'].includes(v); }","tryCatchPattern":"try { await migrateClaudePluginScope({ scope }) }\ncatch (e) {\n  if (e.code === 'INVALID_SCOPE') { console.error(e.message); process.exitCode = 2; }\n  else throw e;\n}","preventionTips":["Only use the documented scope names: user, project, local (lowercase).","Echo shell variables used for --scope before running to catch empty values.","Add CLI arg validation (commander/yargs choices) in wrapper scripts.","Do not invent scope names like 'global'; check `ecc --help`."],"tags":["cli","validation","scope-migration","invalid-argument"],"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"}