jackwener/OpenCLI · error · ArgumentError
channel required
Error message
channel required
What it means
The slock task-list command requires a --channel argument: it trims kwargs.channel and throws an ArgumentError if the result is empty. Since tasks are always fetched per-channel via the API, listing without a channel is unsupported and rejected before any navigation or fetch.
Source
Thrown at clis/slock/task-list.js:37
cli({
site: SLOCK_SITE,
name: 'task-list',
access: 'read',
description: 'List tasks (chat tasks = messages with task fields) attached to a channel. Optional --status filter.',
domain: SLOCK_DOMAIN,
strategy: Strategy.COOKIE,
browser: true,
siteSession: 'persistent',
args: [
{ name: 'channel', positional: true, required: true, help: 'channelId UUID or #name' },
{ name: 'status', help: `Filter by status: ${TASK_STATUSES.join('|')}` },
{ 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 status = kwargs.status ? String(kwargs.status).trim() : '';
if (status && !TASK_STATUSES.includes(status)) {
throw new ArgumentError(`status "${status}" not in {${TASK_STATUSES.join('|')}}`);
}
await page.goto(SLOCK_HOME_URL);
const snippet = `
${authHeadersFragment({ serverScoped: true, serverIdOverride: kwargs.server })}
${channelResolveFragment(channel)}
const status = ${JSON.stringify(status)};
const qs = status ? ('?status=' + encodeURIComponent(status)) : '';
const tres = await fetch('${SLOCK_API_BASE}/tasks/channel/' + encodeURIComponent(channelId) + qs, { credentials:'include', headers });
if (!tres.ok) return { kind: tres.status===401?'auth':'http', status: tres.status, where: '/tasks/channel/:id' };
const data = await tres.json();
// Server contract: { tasks: [...] }. Reject anything else as drift.
if (!data || !Array.isArray(data.tasks)) {
return { kind: 'http', status: 200, where: '/tasks/channel/:id (expected {tasks:[]}, got drift)' };
}
return { kind: 'ok', rows: data.tasks };View on GitHub (pinned to 49907e53dc)
Solutions
- Add the required flag: slock task-list --channel <channel-name>
- If the channel comes from a variable, verify it is non-empty before invoking
- Use slock task-list-server (no channel required) if you want server-wide listing
- Check --help for the exact flag name (--channel) in case of typos like --chan
Example fix
// before
await cli('slock', 'task-list'); // missing channel
// after
await cli('slock', 'task-list', '--channel', 'general'); Defensive patterns
Strategy: validation
Validate before calling
const channel = String(process.env.CHANNEL ?? '').trim();
if (!channel) {
throw new Error('CHANNEL must be set: slock task-list --channel <name>');
} Type guard
const hasChannel = (kwargs) => typeof kwargs?.channel === 'string' && kwargs.channel.trim().length > 0;
Prevention
- Always supply --channel when listing tasks; use task-list-server for server-wide lists
- Check that interpolated shell variables are non-empty
- Add a wrapper that errors early with usage text when --channel is absent
When it happens
Trigger: Running `slock task-list` without --channel, or with --channel '' / only whitespace, or with a variable that was never set so kwargs.channel is undefined.
Common situations: Forgetting the required flag in scripts; shell variable empty due to unset env/config; confusing channel name with channel id and passing an empty override; copy-pasting a command line and dropping the flag.
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
- <train-no> must not be empty
- keyword must not be empty
- <from> station must not be empty
- <to> station must not be empty
- who 不能为空
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/a4f6234f09a1b71a.
Report an issue: GitHub.