{"record":{"id":"1c612365029b4268","repo":"jackwener/OpenCLI","slug":"filter-must-be-one-of-filters-join-go","errorCode":null,"errorMessage":"--filter must be one of ${FILTERS.join(' | ')} (got \"${filter}\")","messagePattern":"--filter must be one of (.+?) \\(got \"(.+?)\"\\)","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/slock/inbox.js","lineNumber":55,"sourceCode":"  site: SLOCK_SITE,\n  name: 'inbox',\n  access: 'read',\n  description: 'List unified inbox items (channels, DMs, followed threads) that need attention.',\n  domain: SLOCK_DOMAIN,\n  strategy: Strategy.COOKIE,\n  browser: true,\n  siteSession: 'persistent',\n  args: [\n    { name: 'filter', default: 'all', help: 'all | unread | mentions' },\n    { name: 'limit', type: 'int', default: 30, help: 'Max items (server caps at 100)' },\n    { name: 'offset', type: 'int', default: 0, help: 'Pagination offset' },\n    { name: 'server', help: 'Override active server' },\n  ],\n  columns: ['kind', 'id', 'name', 'unreadCount', 'hasMention', 'lastActivityAt', 'preview'],\n  func: async (page, kwargs) => {\n    const filter = String(kwargs.filter ?? 'all').toLowerCase();\n    if (!FILTERS.includes(filter)) {\n      throw new ArgumentError(`--filter must be one of ${FILTERS.join(' | ')} (got \"${filter}\")`);\n    }\n    const limit = parsePositiveInteger(kwargs.limit, '--limit', { defaultValue: 30, max: 100 });\n    const offset = parseNonNegativeInteger(kwargs.offset, '--offset', { defaultValue: 0 });\n    await page.goto(SLOCK_HOME_URL);\n    const snippet = buildFetchSnippet({\n      method: 'GET',\n      path: `/channels/inbox?filter=${encodeURIComponent(filter)}&limit=${limit}&offset=${offset}`,\n      serverScoped: true,\n      serverIdOverride: kwargs.server,\n    });\n    const result = await page.evaluate(`(async () => { ${snippet} })()`);\n    const data = dispatchEvaluateResult(result);\n    const items = Array.isArray(data) ? data : (data.items || []);\n    if (!Array.isArray(items)) {\n      throw new CommandExecutionError(`expected inbox items array, got ${typeof items} (contract drift?)`);\n    }\n    return items.map(mapItem);\n  },","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/slock/inbox.js#L37-L73","documentation":"The slock inbox command validates its --filter option against a known FILTERS whitelist and throws ArgumentError listing the allowed values and the offending input. Only specific filter values (e.g. 'all' and similar kinds) are accepted; anything else is rejected before any fetch.","triggerScenarios":"Running `opencli slock inbox --filter unreadz` or a value with different casing/whitespace beyond the toLowerCase() normalization, or an unsupported category like 'mentions' if it's not in FILTERS.","commonSituations":"Guessing filter names instead of checking help; copying filter values from a different CLI tool; typos or trailing spaces in scripts.","solutions":["Run `opencli slock inbox --help` to see the exact allowed FILTERS values","Use one of the listed values verbatim, e.g. `opencli slock inbox --filter all`","Normalize/validate the value in scripts before passing it (lowercase, trim)"],"exampleFix":"// before\nopencli slock inbox --filter Unreadz\n// after\nopencli slock inbox --filter unread","handlingStrategy":"validation","validationCode":"const FILTERS = ['all','unread','mentions']; // from inbox --help\nconst filter = String(process.argv[4] ?? 'all').toLowerCase();\nif (!FILTERS.includes(filter)) { console.error(`--filter must be one of ${FILTERS.join(' | ')}`); process.exit(2); }","typeGuard":"const isValidFilter = (f, allowed) => allowed.includes(String(f ?? 'all').toLowerCase());","tryCatchPattern":"try { await runInbox({ filter }); } catch (e) { if (e instanceof ArgumentError && /--filter/.test(e.message)) { console.error(e.message); process.exit(2); } throw e; }","preventionTips":["Check `slock inbox --help` for the exact FILTERS list","Lowercase and trim filter values in scripts","Don't copy filter names from other tools — verify against this CLI"],"tags":["cli","argument-error","input-validation"],"backgroundTag":"invalid-argument-value","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}