{"record":{"id":"bf2352a78eb16c06","repo":"affaan-m/ECC","slug":"invalid-mode-mode-allowed-modes-allowedmo","errorCode":null,"errorMessage":"Invalid mode \"${mode}\". Allowed modes: ${allowedModes.join(', ')}","messagePattern":"Invalid mode \"(.+?)\"\\. Allowed modes: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"scripts/lib/agent-compress.js","lineNumber":174,"sourceCode":"}\n\nconst allowedModes = ['catalog', 'summary', 'full'];\n\n/**\n * Build a compressed catalog from a directory of agents.\n *\n * Modes:\n *  - 'catalog': name, description, tools, model only (~2-3k tokens for 27 agents)\n *  - 'summary': catalog + first paragraph summary (~4-5k tokens)\n *  - 'full':    no compression, full body included\n *\n * Returns { agents: [], stats: { totalAgents, originalBytes, compressedBytes, compressedTokenEstimate, mode } }\n */\nfunction buildAgentCatalog(agentsDir, options = {}) {\n  const mode = options.mode || 'catalog';\n\n  if (!allowedModes.includes(mode)) {\n    throw new Error(`Invalid mode \"${mode}\". Allowed modes: ${allowedModes.join(', ')}`);\n  }\n\n  const filter = options.filter || null;\n\n  let agents = loadAgents(agentsDir);\n\n  if (typeof filter === 'function') {\n    agents = agents.filter(filter);\n  }\n\n  const originalBytes = agents.reduce((sum, a) => sum + a.byteSize, 0);\n\n  let compressed;\n  if (mode === 'catalog') {\n    compressed = agents.map(compressToCatalog);\n  } else if (mode === 'summary') {\n    compressed = agents.map(compressToSummary);\n  } else {","sourceCodeStart":156,"sourceCodeEnd":192,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/scripts/lib/agent-compress.js#L156-L192","documentation":"Thrown by buildAgentCatalog at scripts/lib/agent-compress.js:173-175 when options.mode is not in the allowedModes list (['catalog', 'summary', 'full']). buildAgentCatalog compresses ECC agent markdown files into a token-budgeted catalog; the mode selects how aggressively each agent is compressed (catalog = metadata only, summary = metadata + first paragraph, full = no compression). The mode defaults to 'catalog' when omitted (ito.js:171 — agent-compress.js:171), so this only fires when an explicit invalid value is supplied.","triggerScenarios":"Calling buildAgentCatalog(agentsDir, { mode: 'compact' }), { mode: 'short' }, { mode: 'metadata' }, or any string other than catalog/summary/full. Also fires on typos like 'catlog' or 'Summry'.","commonSituations":"A caller invented a mode name not in the docs; a refactor renamed a mode but callers were not updated; a config file supplies the mode and a typo slipped in; programmatic callers passing options.compressAs under the wrong key.","solutions":["Use one of: 'catalog', 'summary', 'full' (case-sensitive lowercase).","Omit mode entirely if you want the default ('catalog').","If you need a different compression shape, add it to allowedModes at agent-compress.js:158 and wire a branch into the if/else at lines 188-200."],"exampleFix":"// before\nbuildAgentCatalog(dir, { mode: 'compact' });\n// after\nbuildAgentCatalog(dir, { mode: 'catalog' });","handlingStrategy":"type-guard","validationCode":"const ALLOWED = new Set(['catalog', 'summary', 'full']);\nfunction buildAgentCatalogSafe(dir, options = {}) {\n  const mode = options.mode || 'catalog';\n  if (!ALLOWED.has(mode)) throw new Error(`Invalid mode '${mode}'`);\n  return buildAgentCatalog(dir, { ...options, mode });\n}","typeGuard":"function isAgentCatalogMode(value) {\n  return typeof value === 'string'\n    && ['catalog', 'summary', 'full'].includes(value);\n}","tryCatchPattern":null,"preventionTips":["Default mode to undefined (the function defaults to 'catalog') rather than guessing a name.","Where mode is configured externally (JSON/TOML), validate with isAgentCatalogMode before passing through.","When adding a new mode, update allowedModes and the if/else dispatch together; add a test."],"tags":["javascript","validation","agents","compression","configuration"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}