jackwener/OpenCLI · error · ArgumentError

channel required

Error message

channel required

What it means

The slock channel-members command requires a channel argument (a channelId UUID or #name). The CLI throws this ArgumentError when the positional --channel value is missing or empty after trimming. It is a fail-fast input guard before any browser automation or API call is made.

Source

Thrown at clis/slock/channel-members.js:24

import { SLOCK_SITE, SLOCK_DOMAIN, SLOCK_HOME_URL } from './shared.js';

cli({
  site: SLOCK_SITE,
  name: 'channel-members',
  access: 'read',
  description: 'List members of a channel',
  domain: SLOCK_DOMAIN,
  strategy: Strategy.COOKIE,
  browser: true,
  siteSession: 'persistent',
  args: [
    { name: 'channel', positional: true, required: true, help: 'channelId UUID or #name' },
    { name: 'server', help: 'Override active server (slug or id)' },
  ],
  columns: ['userId', 'name', 'kind', 'role'],
  func: async (page, kwargs) => {
    const channel = String(kwargs.channel ?? '').trim();
    if (!channel) throw new ArgumentError('channel required');
    await page.goto(SLOCK_HOME_URL);
    const snippet = buildChannelScopedSnippet({
      channelInput: channel,
      method: 'GET',
      pathSuffix: '/members',
      serverIdOverride: kwargs.server,
    });
    const result = await page.evaluate(`(async () => { ${snippet} })()`);
    const data = dispatchEvaluateResult(result);
    // F2-a — qatester live dump: response is `{ agents: [...], humans: [...] }`,
    // NOT a flat array and NOT under `.members`. Combine both lists and tag each
    // row with `kind` so the caller can tell agents from humans. Fall back to
    // the legacy shapes (`.members` / `.data` / bare array) for forward-compat.
    let agents = [], humans = [];
    if (Array.isArray(data)) {
      humans = data;
    } else if (data) {
      agents = Array.isArray(data.agents) ? data.agents : [];

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Pass the channel as a positional argument: `opencli slock channel-members '#general'` or `opencli slock channel-members <uuid>`
  2. If using a shell variable, verify it is non-empty before invoking: `[ -n "$CH" ] || { echo 'CH not set'; exit 1; }`
  3. Run `opencli slock channel-list` first to obtain a valid channelId or #name

Example fix

// before
opencli slock channel-members
// after
opencli slock channel-members '#general'
Defensive patterns

Strategy: validation

Validate before calling

const channel = (process.argv[3] ?? '').trim();
if (!channel) { console.error('usage: opencli slock channel-members <channelId|#name>'); process.exit(2); }

Type guard

const isNonEmptyString = (v) => typeof v === 'string' && v.trim().length > 0;

Try / catch

try { await runChannelMembers(channel); } catch (e) { if (e instanceof ArgumentError) { console.error('Missing --channel:', e.message); process.exit(2); } throw e; }

Prevention

When it happens

Trigger: Running `opencli slock channel-members` without the positional channel argument, or passing only whitespace/empty string (e.g. from a shell variable that expanded to empty: `opencli slock channel-members "$CH"` where CH is unset).

Common situations: Shell scripts with unset/empty channel variables; copy-pasting the command from docs without filling in the channel; forgetting that the channel is positional and trying `--channel` with the wrong subcommand placement.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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