jackwener/OpenCLI · error · ArgumentError

channel required

Error message

channel required

What it means

task-get requires a `channel` option; the func trims it and throws ArgumentError when empty, before validating the task number. The channel is needed to resolve the per-channel taskNumber via channelResolveFragment.

Source

Thrown at clis/slock/task-get.js:33

cli({
  site: SLOCK_SITE,
  name: 'task-get',
  access: 'read',
  description: 'Fetch a task by channel + taskNumber (GET /tasks/channel/:channelId/number/:taskNumber).',
  domain: SLOCK_DOMAIN,
  strategy: Strategy.COOKIE,
  browser: true,
  siteSession: 'persistent',
  args: [
    { name: 'channel', positional: true, required: true, help: 'channelId UUID or #name' },
    { name: 'number', positional: true, required: true, help: 'taskNumber (per-channel integer, as shown in "task #N")' },
    { name: 'server', help: 'Override active server' },
  ],
  columns: ['id', 'taskNumber', 'title', 'taskStatus', 'assigneeId'],
  func: async (page, kwargs) => {
    const channel = String(kwargs.channel ?? '').trim();
    if (!channel) throw new ArgumentError('channel required');
    const numRaw = String(kwargs.number ?? '').trim();
    if (!/^\d+$/.test(numRaw)) throw new ArgumentError(`number "${numRaw}" is not a positive integer`);
    const number = parsePositiveInteger(numRaw, 'number');
    await page.goto(SLOCK_HOME_URL);
    const snippet = `
      ${authHeadersFragment({ serverScoped: true, serverIdOverride: kwargs.server })}
      ${channelResolveFragment(channel)}
      const res = await fetch('${SLOCK_API_BASE}/tasks/channel/' + encodeURIComponent(channelId) + '/number/' + encodeURIComponent(${JSON.stringify(String(number))}), { credentials:'include', headers });
      if (res.status === 404) return { kind: 'http', status: 404, where: '/tasks/channel/:id/number/:n (task #' + ${JSON.stringify(number)} + ' not found in channel)' };
      if (!res.ok) return { kind: res.status===401?'auth':'http', status: res.status, where:'/tasks/channel/:id/number/:n' };
      const data = await res.json().catch(() => ({}));
      // Single object or {task: ...} wrapped — accept either.
      const task = data && data.task ? data.task : data;
      return { kind: 'ok', rows: [task] };
    `;
    const result = await page.evaluate(`(async () => { ${snippet} })()`);
    const rows = dispatchEvaluateResult(result);
    return rows.map((t) => ({

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Pass --channel with the target channel, e.g. --channel general.
  2. Verify the variable/config supplying the channel name is populated.
  3. If unsure of the channel slug, list channels first and use the exact slug.

Example fix

// before
slock task-get "$CHANNEL" 5   # CHANNEL empty
// after
slock task-get --channel general --number 5
Defensive patterns

Strategy: validation

Validate before calling

const channel = String(opts.channel ?? '').trim();
if (!channel) throw new Error('channel is required for task-get');
if (!/^\d+$/.test(number)) throw new Error(`number must be a positive integer, got: ${number}`);

Type guard

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

Try / catch

try {
  await cli('task-get', ['--channel', channel, '--number', String(number)]);
} catch (e) {
  if (e instanceof ArgumentError && e.message === 'channel required') {
    console.error('Pass --channel <slug> along with --number.');
    process.exitCode = 2;
  } else throw e;
}

Prevention

When it happens

Trigger: Running task-get without --channel, or with --channel set to empty/whitespace.

Common situations: Omitting the flag in scripts that assume a default channel exists; env/config variable for the channel unset; copying an example command that used a placeholder channel.

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/29ec1b24389d759c. Report an issue: GitHub.