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

  1. Pass a name: `slock channel-create --name my-channel`
  2. If using a shell variable, verify it is set: `${CHANNEL:?CHANNEL not set}`
  3. 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

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


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/35c2901f38620367. Report an issue: GitHub.