jackwener/OpenCLI · error · ArgumentError
name required
Error message
name required
What it means
`channel-create` requires a non-empty `--name`. The CLI trims the `name` kwarg and throws ArgumentError('name required') when it is missing, an empty string, or only whitespace, before any request is made to Slock.
Source
Thrown at clis/slock/channel-create.js:29
cli({
site: SLOCK_SITE,
name: 'channel-create',
access: 'write',
description: 'Create a channel — admin only (POST /channels/). Public unless --private.',
domain: SLOCK_DOMAIN,
strategy: Strategy.COOKIE,
browser: true,
siteSession: 'persistent',
args: [
{ name: 'name', positional: true, required: true, help: 'Channel name' },
{ name: 'description', help: 'Channel description / topic (≤500 chars)' },
{ name: 'private', type: 'bool', default: false, help: 'Create a private channel instead of public' },
{ name: 'server', help: 'Override active server' },
],
columns: ['id', 'name', 'type', 'result'],
func: async (page, kwargs) => {
const name = String(kwargs.name ?? '').trim();
if (!name) throw new ArgumentError('name required');
const description = kwargs.description !== undefined ? String(kwargs.description) : undefined;
if (description !== undefined && description.length > 500) {
throw new ArgumentError('--description must be at most 500 characters');
}
const body = { name, visibility: kwargs.private ? 'private' : 'public' };
if (description !== undefined) body.description = description;
await page.goto(SLOCK_HOME_URL);
const snippet = buildFetchSnippet({
method: 'POST',
path: '/channels/',
body,
serverScoped: true,
serverIdOverride: kwargs.server,
});
const result = await page.evaluate(`(async () => { ${snippet} })()`);
const data = dispatchEvaluateResult(result);
return [{ id: data?.id ?? '', name: data?.name ?? name, type: data?.type ?? '', result: 'created' }];
},View on GitHub (pinned to 49907e53dc)
Solutions
- Pass a name: `slock channel-create --name my-channel`
- If using a shell variable, verify it is set: `${CHANNEL:?CHANNEL not set}`
- Check quoting so the value is not consumed by the shell
Example fix
// before $ slock channel-create --private Error: name required // after $ slock channel-create --name ops --private
Defensive patterns
Strategy: validation
Validate before calling
const name = String(process.env.CHANNEL_NAME ?? '').trim();
if (!name) throw new Error('CHANNEL_NAME must be a non-empty channel name before running channel-create'); Type guard
const isValidName = (v) => typeof v === 'string' && v.trim().length > 0;
Try / catch
try {
await run(['slock', 'channel-create', '--name', name]);
} catch (e) {
if (e instanceof ArgumentError && e.message === 'name required') {
console.error('Pass --name <channelName>; the value was empty after trimming.');
} else throw e;
} Prevention
- Always quote --name values in shell scripts
- Use ${VAR:?msg} to fail fast on unset variables
- Trim and check user-supplied names before passing them to the CLI
When it happens
Trigger: Calling `slock channel-create` without `--name`, or with `--name ""` or `--name " "` (whitespace-only after trim).
Common situations: Shell variable interpolation yields an empty value (`--name "$CHANNEL"` where CHANNEL is unset), a config/CI pipeline drops the flag, or copy-paste omits the 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/35c2901f38620367.
Report an issue: GitHub.