jackwener/OpenCLI · error · ArgumentError
channel required
Error message
channel required
What it means
`channel-files` requires a target channel. The CLI trims the `channel` kwarg and throws ArgumentError('channel required') when it is missing or empty, before navigating or building the fetch snippet.
Source
Thrown at clis/slock/channel-files.js:26
cli({
site: SLOCK_SITE,
name: 'channel-files',
access: 'read',
description: 'List files shared in a channel (GET /channels/:id/files)',
domain: SLOCK_DOMAIN,
strategy: Strategy.COOKIE,
browser: true,
siteSession: 'persistent',
args: [
{ name: 'channel', positional: true, required: true, help: 'channelId UUID or #name' },
{ name: 'limit', type: 'int', default: 50, help: 'Max files' },
{ name: 'server', help: 'Override active server' },
],
columns: ['id', 'filename', 'mimeType', 'sizeBytes', 'messageId', 'createdAt'],
func: async (page, kwargs) => {
const channel = String(kwargs.channel ?? '').trim();
if (!channel) throw new ArgumentError('channel required');
const limit = parsePositiveInteger(kwargs.limit, '--limit', { defaultValue: 50 });
await page.goto(SLOCK_HOME_URL);
const snippet = buildChannelScopedSnippet({
channelInput: channel,
method: 'GET',
pathSuffix: '/files',
query: `?limit=${limit}`,
serverIdOverride: kwargs.server,
});
const result = await page.evaluate(`(async () => { ${snippet} })()`);
const data = dispatchEvaluateResult(result);
const files = Array.isArray(data) ? data : (data.files || []);
if (!Array.isArray(files)) {
throw new CommandExecutionError(`expected files array, got ${typeof files} (contract drift?)`);
}
return files.map((f) => ({
id: f.id ?? '',
filename: f.filename ?? '',View on GitHub (pinned to 49907e53dc)
Solutions
- Pass the channel: `slock channel-files --channel '#ops'` or the channelId UUID
- Verify the variable feeding --channel is non-empty before invoking
- Check the command's help (`slock channel-files --help`) for the expected flag
Example fix
// before $ slock channel-files --limit 10 Error: channel required // after $ slock channel-files --channel '#ops' --limit 10
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-files', '--channel', channel]);
} catch (e) {
if (e instanceof ArgumentError && e.message === 'channel required') {
console.error('Pass --channel <#name|uuid>; the value was empty.');
} else throw e;
} Prevention
- Make --channel explicit in every invocation
- Skip empty entries when looping over channel lists
- Wrap the CLI in a helper that asserts required args
When it happens
Trigger: Calling `slock channel-files` without `--channel`, or with an empty/whitespace-only value.
Common situations: Scripting loops where the channel variable is unset for some iterations, forgetting the positional/flag in an alias, or a wrapper script that forwards kwargs incorrectly.
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/606df37147b2d877.
Report an issue: GitHub.