jackwener/OpenCLI · error · ArgumentError

--filter must be one of ${FILTERS.join(' | ')} (got "${filte

Error message

--filter must be one of ${FILTERS.join(' | ')} (got "${filter}")

What it means

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.

Source

Thrown at clis/slock/inbox.js:55

  site: SLOCK_SITE,
  name: 'inbox',
  access: 'read',
  description: 'List unified inbox items (channels, DMs, followed threads) that need attention.',
  domain: SLOCK_DOMAIN,
  strategy: Strategy.COOKIE,
  browser: true,
  siteSession: 'persistent',
  args: [
    { name: 'filter', default: 'all', help: 'all | unread | mentions' },
    { name: 'limit', type: 'int', default: 30, help: 'Max items (server caps at 100)' },
    { name: 'offset', type: 'int', default: 0, help: 'Pagination offset' },
    { name: 'server', help: 'Override active server' },
  ],
  columns: ['kind', 'id', 'name', 'unreadCount', 'hasMention', 'lastActivityAt', 'preview'],
  func: async (page, kwargs) => {
    const filter = String(kwargs.filter ?? 'all').toLowerCase();
    if (!FILTERS.includes(filter)) {
      throw new ArgumentError(`--filter must be one of ${FILTERS.join(' | ')} (got "${filter}")`);
    }
    const limit = parsePositiveInteger(kwargs.limit, '--limit', { defaultValue: 30, max: 100 });
    const offset = parseNonNegativeInteger(kwargs.offset, '--offset', { defaultValue: 0 });
    await page.goto(SLOCK_HOME_URL);
    const snippet = buildFetchSnippet({
      method: 'GET',
      path: `/channels/inbox?filter=${encodeURIComponent(filter)}&limit=${limit}&offset=${offset}`,
      serverScoped: true,
      serverIdOverride: kwargs.server,
    });
    const result = await page.evaluate(`(async () => { ${snippet} })()`);
    const data = dispatchEvaluateResult(result);
    const items = Array.isArray(data) ? data : (data.items || []);
    if (!Array.isArray(items)) {
      throw new CommandExecutionError(`expected inbox items array, got ${typeof items} (contract drift?)`);
    }
    return items.map(mapItem);
  },

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Run `opencli slock inbox --help` to see the exact allowed FILTERS values
  2. Use one of the listed values verbatim, e.g. `opencli slock inbox --filter all`
  3. Normalize/validate the value in scripts before passing it (lowercase, trim)

Example fix

// before
opencli slock inbox --filter Unreadz
// after
opencli slock inbox --filter unread
Defensive patterns

Strategy: validation

Validate before calling

const FILTERS = ['all','unread','mentions']; // from inbox --help
const filter = String(process.argv[4] ?? 'all').toLowerCase();
if (!FILTERS.includes(filter)) { console.error(`--filter must be one of ${FILTERS.join(' | ')}`); process.exit(2); }

Type guard

const isValidFilter = (f, allowed) => allowed.includes(String(f ?? 'all').toLowerCase());

Try / catch

try { await runInbox({ filter }); } catch (e) { if (e instanceof ArgumentError && /--filter/.test(e.message)) { console.error(e.message); process.exit(2); } throw e; }

Prevention

When it happens

Trigger: 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.

Common situations: Guessing filter names instead of checking help; copying filter values from a different CLI tool; typos or trailing spaces in scripts.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/1c612365029b4268. Report an issue: GitHub.