jackwener/OpenCLI · error · ArgumentError
title required (non-empty)
Error message
title required (non-empty)
What it means
task-create requires a non-empty `title`; the func trims the value and throws ArgumentError when empty. Titles are mandatory because the backend task object is built from { title, description? }.
Source
Thrown at clis/slock/task-create.js:44
name: 'task-create',
access: 'write',
description: 'Create a task in a channel (single title; batch 1-50 is server-supported but client surface is single — see backlog R4).',
domain: SLOCK_DOMAIN,
strategy: Strategy.COOKIE,
browser: true,
siteSession: 'persistent',
args: [
{ name: 'channel', positional: true, required: true, help: 'channelId UUID or #name' },
{ name: 'title', positional: true, required: true, help: 'Task title (single; batch TODO via R4)' },
{ name: 'desc', help: 'Optional description body for the task' },
{ name: 'server', help: 'Override active server' },
],
columns: ['id', 'taskNumber', 'title', 'taskStatus', 'channelId'],
func: async (page, kwargs) => {
const channel = String(kwargs.channel ?? '').trim();
if (!channel) throw new ArgumentError('channel required');
const title = String(kwargs.title ?? '').trim();
if (!title) throw new ArgumentError('title required (non-empty)');
const desc = kwargs.desc != null ? String(kwargs.desc) : '';
await page.goto(SLOCK_HOME_URL);
const taskObj = desc ? { title, description: desc } : { title };
const snippet = `
${authHeadersFragment({ serverScoped: true, serverIdOverride: kwargs.server })}
${channelResolveFragment(channel)}
// Body is always a batch array — N=1 here because the CLI exposes one
// title at a time (R4 will widen this). Keep the wrapper so the server
// sees the same shape as a real batch and we don't fork the contract.
const body = { tasks: [${JSON.stringify(taskObj)}] };
const res = await fetch('${SLOCK_API_BASE}/tasks/channel/' + encodeURIComponent(channelId), {
method:'POST', credentials:'include', headers, body: JSON.stringify(body),
});
if (res.status === 400) {
const j = await res.json().catch(() => ({}));
return { kind: 'http', status: 400, where: '/tasks/channel/:id (bad request: ' + (j.error || j.message || 'title/limit/shape') + ')' };
}
if (res.status === 403) return { kind: 'http', status: 403, where: '/tasks/channel/:id (forbidden — channel archived or not a member)' };View on GitHub (pinned to 49907e53dc)
Solutions
- Pass --title with a non-empty string, quoted if it contains spaces.
- Validate the title variable is non-empty before composing the command.
- Always quote the flag value: --title "My task title".
Example fix
// before
slock task-create --channel general --title $TITLE
// after
slock task-create --channel general --title "${TITLE:?title required}" Defensive patterns
Strategy: validation
Validate before calling
const title = String(opts.title ?? '').trim();
if (!title) throw new Error('title must be a non-empty string'); Type guard
const hasTitle = (v) => typeof v === 'string' && v.trim().length > 0;
Try / catch
try {
await cli('task-create', ['--channel', channel, '--title', title]);
} catch (e) {
if (e instanceof ArgumentError && e.message.includes('title required')) {
console.error('Provide a non-empty --title value (quote it if it has spaces).');
process.exitCode = 2;
} else throw e;
} Prevention
- Always quote --title values in shell commands.
- Trim and validate titles at the call site before invoking the CLI.
- Never rely on desc alone; title is mandatory.
When it happens
Trigger: Running task-create without --title, with --title "" or --title " ", or with quoting that collapses the value (e.g. --title $UNSET).
Common situations: Scripts building the command from variables where title is empty; unquoted shell variables losing whitespace-only titles; assuming a desc alone suffices.
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
- lobsters domain is required (e.g. "github.com" or "arxiv.org
- input required: slug or UUID
- messageId required
- channel required
- channel required
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/811ea9fd9eba9fe3.
Report an issue: GitHub.