{"record":{"id":"de7c6a87c84135b8","repo":"affaan-m/ECC","slug":"invalid-scope-scope","errorCode":null,"errorMessage":"Invalid scope: ${scope}","messagePattern":"Invalid scope: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/harness-audit.js","lineNumber":65,"sourceCode":"  },\n  Fly: {\n    detect: (rootDir) => fileExists(rootDir, 'fly.toml'),\n    keyPattern: /fly[_-]?(api|io)/i,\n    buildPattern: /fly\\s+(deploy|launch)/i,\n    workflowPattern: /(superfly\\/flyctl-actions|flyctl\\s+deploy|fly\\s+deploy)/i,\n  },\n};\n\nfunction getApplicableProviders(rootDir) {\n  return Object.entries(PROVIDERS)\n    .filter(([_, spec]) => spec.detect(rootDir))\n    .map(([name]) => name);\n}\n\nfunction normalizeScope(scope) {\n  const value = (scope || 'repo').toLowerCase();\n  if (!['repo', 'hooks', 'skills', 'commands', 'agents'].includes(value)) {\n    throw new Error(`Invalid scope: ${scope}`);\n  }\n  return value;\n}\n\nfunction parseArgs(argv) {\n  const args = argv.slice(2);\n  const parsed = {\n    scope: 'repo',\n    format: 'text',\n    help: false,\n    root: path.resolve(process.env.AUDIT_ROOT || process.cwd()),\n  };\n\n  for (let index = 0; index < args.length; index += 1) {\n    const arg = args[index];\n\n    if (arg === '--help' || arg === '-h') {\n      parsed.help = true;","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/harness-audit.js#L47-L83","documentation":"normalizeScope in scripts/harness-audit.js lowercases the given scope (defaulting to 'repo') and requires it to be one of repo, hooks, skills, commands, or agents; otherwise it throws `Invalid scope: <value>`. The scope selects which part of the project the audit examines.","triggerScenarios":"Passing --scope=agent (singular) or --scope=all; uppercase values are lowercased first so case alone won't trigger it — the trigger is a value outside the five-element allowlist; calling normalizeScope programmatically with a slug from another tool.","commonSituations":"Guessing scope names without reading usage; reusing a scope list from a different audit script; automation templates passing a scope placeholder like ${SCOPE} that expands to 'none' or 'all'.","solutions":["Use one of: repo, hooks, skills, commands, agents.","Fix singular/plural mistakes (agents, not agent).","Check the variable feeding --scope in your automation for empty or placeholder values.","If you need a combined audit, run the script once per scope instead of inventing an 'all' value."],"exampleFix":"// before\nnode scripts/harness-audit.js --scope=all\n\n// after\nnode scripts/harness-audit.js --scope=hooks","handlingStrategy":"validation","validationCode":"const SCOPES = ['repo', 'hooks', 'skills', 'commands', 'agents'];\nconst scope = (raw || 'repo').toLowerCase();\nif (!SCOPES.includes(scope)) {\n  throw new Error(`Invalid scope: ${raw}. Use one of ${SCOPES.join(', ')}`);\n}","typeGuard":"const isScope = (s) =>\n  ['repo','hooks','skills','commands','agents'].includes((s || '').toLowerCase());","tryCatchPattern":"try {\n  const scope = normalizeScope(rawScope);\n} catch (e) {\n  if (e.message.startsWith('Invalid scope:')) {\n    console.error(e.message + ' — valid scopes: repo, hooks, skills, commands, agents');\n    process.exit(2);\n  }\n  throw e;\n}","preventionTips":["Use plural scope names exactly: agents, commands, skills, hooks, repo.","Don't invent 'all' — loop over the five scopes instead.","Validate scope placeholders in CI templates before expansion.","Keep the allowlist in one shared constant between caller and callee."],"tags":["cli","validation","enum"],"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"}