affaan-m/ECC · error · Error
Invalid mode " ". Allowed modes
Error message
Invalid mode "${mode}". Allowed modes: ${allowedModes.join(', ')} What it means
buildAgentCatalog accepts only the modes 'catalog', 'summary', or 'full' (allowedModes). The mode controls compression level of the agent catalog output. Passing any other string throws immediately before any files are read, so mistakes fail fast.
Solutions
- Use one of the exact strings: 'catalog', 'summary', or 'full' (default is 'catalog' when mode is omitted).
- If the value comes from user input, map or validate it against allowedModes before calling.
- Check casing — the comparison is case-sensitive, so 'Summary' must be 'summary'.
- Omit the mode option entirely if you want the default catalog behavior.
Example fix
// before
buildAgentCatalog('agents/', { mode: 'Catalog' });
// after
buildAgentCatalog('agents/', { mode: 'catalog' }); Defensive patterns
Strategy: validation
Validate before calling
const allowed = ['catalog', 'summary', 'full'];
if (!allowed.includes(mode)) throw new Error(`mode must be one of ${allowed.join(', ')}`); Type guard
const isCatalogMode = (m) => m === 'catalog' || m === 'summary' || m === 'full';
Try / catch
try { buildAgentCatalog(dir, { mode }); } catch (e) { if (e.message.startsWith('Invalid mode')) { console.error('Use catalog | summary | full'); } else throw e; } Prevention
- Map CLI flags to the mode enum explicitly instead of passing raw strings
- Remember the comparison is case-sensitive
- Omit mode for the default 'catalog' behavior
When it happens
Trigger: Calling buildAgentCatalog(dir, { mode: 'compressed' }) or { mode: 'Catalog' } (case-sensitive), or wiring a CLI flag/option string like 'c' or 'minified' straight into options.mode.
Common situations: Typo or wrong casing in a script that generates token-budgeted catalogs; passing a user-supplied CLI argument without mapping it to the enum; renaming modes in custom forks without updating callers.
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/bf2352a78eb16c06.
Report an issue: GitHub.
Appendix: source
Thrown at scripts/lib/agent-compress.js:174
}
const allowedModes = ['catalog', 'summary', 'full'];
/**
* Build a compressed catalog from a directory of agents.
*
* Modes:
* - 'catalog': name, description, tools, model only (~2-3k tokens for 27 agents)
* - 'summary': catalog + first paragraph summary (~4-5k tokens)
* - 'full': no compression, full body included
*
* Returns { agents: [], stats: { totalAgents, originalBytes, compressedBytes, compressedTokenEstimate, mode } }
*/
function buildAgentCatalog(agentsDir, options = {}) {
const mode = options.mode || 'catalog';
if (!allowedModes.includes(mode)) {
throw new Error(`Invalid mode "${mode}". Allowed modes: ${allowedModes.join(', ')}`);
}
const filter = options.filter || null;
let agents = loadAgents(agentsDir);
if (typeof filter === 'function') {
agents = agents.filter(filter);
}
const originalBytes = agents.reduce((sum, a) => sum + a.byteSize, 0);
let compressed;
if (mode === 'catalog') {
compressed = agents.map(compressToCatalog);
} else if (mode === 'summary') {
compressed = agents.map(compressToSummary);
} else {View on GitHub (pinned to 8321021c54)