jackwener/OpenCLI · error · ArgumentError

--description must be at most 500 characters

Error message

--description must be at most 500 characters

What it means

`channel-create` enforces Slock's 500-character limit on the channel description. The CLI validates the trimmed string length client-side and throws ArgumentError before issuing the create request, avoiding a doomed API call.

Source

Thrown at clis/slock/channel-create.js:32

  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. Shorten the description to 500 characters or fewer
  2. Truncate programmatically before passing: `--description "$(echo "$DESC" | head -c 500)"`
  3. Move long content into the channel topic or a linked doc and keep the description brief

Example fix

// before
$ slock channel-create --name ops --description "$(cat long-policy.md)"  # 4200 chars
Error: --description must be at most 500 characters
// after
$ slock channel-create --name ops --description "$(head -c 500 long-policy.md)"
Defensive patterns

Strategy: validation

Validate before calling

const description = String(input.description ?? '');
if (description.length > 500) {
  throw new Error(`description is ${description.length} chars; must be <= 500`);
}

Try / catch

try {
  await run(['slock', 'channel-create', '--name', name, '--description', description]);
} catch (e) {
  if (e instanceof ArgumentError && /at most 500 characters/.test(e.message)) {
    description = description.slice(0, 500);
    await run(['slock', 'channel-create', '--name', name, '--description', description]);
  } else throw e;
}

Prevention

When it happens

Trigger: Running `slock channel-create --name x --description "..."` where the description string exceeds 500 characters.

Common situations: Pasting a long document/README excerpt as the description, or generating descriptions from templates that don't truncate. Also happens when CI passes a multi-line team policy text.

Related errors


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