affaan-m/ECC · error · Error
Invalid scope
Error message
Invalid scope: ${scope} What it means
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.
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.
Example fix
// before node scripts/harness-audit.js --scope=all // after node scripts/harness-audit.js --scope=hooks
Defensive patterns
Strategy: validation
Validate before calling
const SCOPES = ['repo', 'hooks', 'skills', 'commands', 'agents'];
const scope = (raw || 'repo').toLowerCase();
if (!SCOPES.includes(scope)) {
throw new Error(`Invalid scope: ${raw}. Use one of ${SCOPES.join(', ')}`);
} Type guard
const isScope = (s) => ['repo','hooks','skills','commands','agents'].includes((s || '').toLowerCase());
Try / catch
try {
const scope = normalizeScope(rawScope);
} catch (e) {
if (e.message.startsWith('Invalid scope:')) {
console.error(e.message + ' — valid scopes: repo, hooks, skills, commands, agents');
process.exit(2);
}
throw e;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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'.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- --host-provider must be anthropic, openai, or unknown
- Invalid --action value
- Invalid format: . Use text, json, or markdown.
- Invalid format: . Use text, json, or markdown.
- Invalid format: . Use text, json, or markdown.
AI-assisted analysis of affaan-m/ECC@8321021c54 (2026-09-16).
Data as JSON: /api/errors/de7c6a87c84135b8.
Report an issue: GitHub.
Appendix: source
Thrown at scripts/harness-audit.js:65
},
Fly: {
detect: (rootDir) => fileExists(rootDir, 'fly.toml'),
keyPattern: /fly[_-]?(api|io)/i,
buildPattern: /fly\s+(deploy|launch)/i,
workflowPattern: /(superfly\/flyctl-actions|flyctl\s+deploy|fly\s+deploy)/i,
},
};
function getApplicableProviders(rootDir) {
return Object.entries(PROVIDERS)
.filter(([_, spec]) => spec.detect(rootDir))
.map(([name]) => name);
}
function normalizeScope(scope) {
const value = (scope || 'repo').toLowerCase();
if (!['repo', 'hooks', 'skills', 'commands', 'agents'].includes(value)) {
throw new Error(`Invalid scope: ${scope}`);
}
return value;
}
function parseArgs(argv) {
const args = argv.slice(2);
const parsed = {
scope: 'repo',
format: 'text',
help: false,
root: path.resolve(process.env.AUDIT_ROOT || process.cwd()),
};
for (let index = 0; index < args.length; index += 1) {
const arg = args[index];
if (arg === '--help' || arg === '-h') {
parsed.help = true;View on GitHub (pinned to 8321021c54)