jackwener/OpenCLI · error · ArgumentError
channel required
Error message
channel required
What it means
message-read.js requires a `channel` argument identifying which channel's messages to read. If the kwarg is missing or an empty/whitespace string after trimming, it throws ArgumentError('channel required').
Source
Thrown at clis/slock/message-read.js:45
name: 'message-read',
access: 'read',
description: 'Read messages in a channel or thread. Thread form: "#channel:msgIdOrShort". Use --after seq|UUID for cursor.',
domain: SLOCK_DOMAIN,
strategy: Strategy.COOKIE,
browser: true,
siteSession: 'persistent',
args: [
{ name: 'channel', positional: true, required: true, help: 'channelId UUID, "#name", or "#channel:msgIdOrShort"' },
{ name: 'after', help: 'Cursor: seq number or messageId UUID (exclusive)' },
{ name: 'before', help: 'seq to page before' },
{ name: 'limit', type: 'int', default: 50, help: 'Max messages' },
{ name: 'no-threads', type: 'bool', default: false, help: 'Skip /threads enrichment' },
{ name: 'server', help: 'Override active server' },
],
columns: ['id', 'seq', 'createdAt', 'senderName', 'content', 'threadChannelId', 'replyCount', 'unreadCount', 'lastReplyAt'],
func: async (page, kwargs) => {
const channel = String(kwargs.channel ?? '').trim();
if (!channel) throw new ArgumentError('channel required');
const tt = classifyThreadTarget(channel);
const isUuid = UUID_RE.test(channel);
const after = kwargs.after !== undefined ? String(kwargs.after) : '';
if (after && !/^\d+$/.test(after) && !UUID_RE.test(after)) {
throw new ArgumentError(`--after must be a seq number or messageId UUID (got "${after}")`);
}
const limit = parsePositiveInteger(kwargs.limit, '--limit', { defaultValue: 50 });
const before = kwargs.before !== undefined ? String(kwargs.before) : '';
if (before && !/^\d+$/.test(before)) {
throw new ArgumentError(`--before must be a seq number (got "${before}")`);
}
if (before) parsePositiveInteger(before, '--before');
const noThreads = !!kwargs['no-threads'];
// R1 — pass the raw override through to authHeadersFragment; it owns the
// UUID-vs-slug resolution against /servers/ now.
const override = kwargs.server ?? null;
await page.goto(SLOCK_HOME_URL);View on GitHub (pinned to 49907e53dc)
Solutions
- Pass the channel: e.g. `--channel #general` or the channel UUID.
- Check the value sourcing the flag is defined and non-empty (env var, previous command output).
- Run the command's help to confirm the exact flag name.
Example fix
// before
await run('message-read', {});
// after
await run('message-read', { channel: '#general' }); Defensive patterns
Strategy: validation
Validate before calling
if (!kwargs.channel || !String(kwargs.channel).trim()) throw new Error('message-read: --channel is required'); Type guard
const channel = typeof kwargs.channel === 'string' && kwargs.channel.trim() ? kwargs.channel.trim() : null;
if (!channel) throw new Error('channel required'); Try / catch
try { await readMessages(page, kwargs); } catch (e) { if (e instanceof ArgumentError && e.message === 'channel required') { console.error('Usage: message-read --channel <#slug|uuid>'); } else throw e; } Prevention
- Always include --channel in message-read invocations/scripts
- Validate kwargs objects before dispatching CLI commands
- Keep channel identifiers in a config file and assert non-empty at startup
When it happens
Trigger: Calling the message-read command without `--channel`, or with `--channel ""` / only whitespace.
Common situations: Forgetting the flag in a scripted invocation; passing a variable that is undefined/null; copy-pasting a command and dropping the channel argument.
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
- symbol is required
- Either --product-id or --url is required
- --city is required (numeric city ID from `ctrip search` or `
- --${name} is required (e.g. 北京 / 上海)
- hotel id is required (numeric id from `ctrip hotel-suggest`,
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/6975334f94b7954d.
Report an issue: GitHub.