jackwener/OpenCLI · error · ArgumentError
channel required
Error message
channel required
What it means
`channel-info` requires a target channel identifier. The CLI trims the `channel` kwarg and throws ArgumentError('channel required') when it is missing or empty, before resolving the channel via `buildChannelScopedSnippet`.
Source
Thrown at clis/slock/channel-info.js:24
import { SLOCK_SITE, SLOCK_DOMAIN, SLOCK_HOME_URL } from './shared.js';
cli({
site: SLOCK_SITE,
name: 'channel-info',
access: 'read',
description: 'Show one channel\'s details (GET /channels/:id)',
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' },
],
columns: ['id', 'name', 'type', 'topic', 'joined', 'archivedAt'],
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',
serverIdOverride: kwargs.server,
});
const result = await page.evaluate(`(async () => { ${snippet} })()`);
const c = dispatchEvaluateResult(result) || {};
return [{
id: c.id ?? '',
name: c.name ?? c.slug ?? '',
type: c.type ?? '',
topic: c.topic ?? c.description ?? '',
joined: c.joined ?? null,
archivedAt: c.archivedAt ?? null,
}];
},
});View on GitHub (pinned to 49907e53dc)
Solutions
- Provide the channel: `slock channel-info '#ops'` or the channelId UUID
- Guard variables in scripts: `: "${CHANNEL:?channel not set}"`
- Run `slock channel-info --help` to confirm argument syntax
Example fix
// before $ slock channel-info Error: channel required // after $ slock channel-info '#ops'
Defensive patterns
Strategy: validation
Validate before calling
const channel = String(input.channel ?? '').trim();
if (!channel) throw new Error('channel must be provided (#name or channelId UUID)'); Type guard
const hasChannel = (v) => typeof v === 'string' && v.trim().length > 0;
Try / catch
try {
await run(['slock', 'channel-info', channel]);
} catch (e) {
if (e instanceof ArgumentError && e.message === 'channel required') {
console.error('Pass the channel positionally: slock channel-info <#name|uuid>.');
} else throw e;
} Prevention
- Pass the channel as a positional argument, quoted if it starts with #
- Validate variables before invoking in scripts
- Quote #names so the shell does not treat # as a comment
When it happens
Trigger: Calling `slock channel-info` without the positional/`--channel` value, or with an empty string after trimming.
Common situations: Automation passing an unset variable, interactive users forgetting the positional argument (the arg is marked required:true but empty strings still slip through), or quoting bugs that yield "".
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/ee5ec6fd6fcf707c.
Report an issue: GitHub.