jackwener/OpenCLI · error · ArgumentError
channel required
Error message
channel required
What it means
The slock inbox-done command requires a channel argument (channelId UUID or #name). Like channel-members, it throws ArgumentError when the positional --channel value is missing or blank. The fail-fast guard runs before page navigation and the POST to /channels/inbox/done.
Source
Thrown at clis/slock/inbox-done.js:24
import { SLOCK_SITE, SLOCK_DOMAIN, SLOCK_HOME_URL, SLOCK_API_BASE } from './shared.js';
cli({
site: SLOCK_SITE,
name: 'inbox-done',
access: 'write',
description: 'Mark one chat as done / clear it from the inbox (POST /channels/inbox/done)',
domain: SLOCK_DOMAIN,
strategy: Strategy.COOKIE,
browser: true,
siteSession: 'persistent',
args: [
{ name: 'channel', positional: true, required: true, help: 'channelId UUID or #name' },
{ name: 'server', help: 'Override active server' },
],
columns: ['channel', 'result'],
func: async (page, kwargs) => {
const channel = String(kwargs.channel ?? '').trim();
if (!channel) throw new ArgumentError('channel required');
await page.goto(SLOCK_HOME_URL);
// channelId travels in the BODY (not the URL), so resolve then POST the fixed path.
const snippet = `
${authHeadersFragment({ serverScoped: true, serverIdOverride: kwargs.server })}
${channelResolveFragment(channel)}
const res = await fetch('${SLOCK_API_BASE}/channels/inbox/done', { method:'POST', credentials:'include', headers, body: JSON.stringify({ channelId }) });
if (res.status === 401) return { kind: 'auth', detail: '/channels/inbox/done returned 401' };
if (!res.ok) return { kind: 'http', status: res.status, where:'/channels/inbox/done' };
const data = await res.json().catch(() => ({}));
return { kind: 'ok', rows: data };
`;
const result = await page.evaluate(`(async () => { ${snippet} })()`);
dispatchEvaluateResult(result);
return [{ channel, result: 'done' }];
},
});
View on GitHub (pinned to 49907e53dc)
Solutions
- Provide the channel: `opencli slock inbox-done '#general'` or with a UUID
- Get a valid id via `opencli slock inbox` (the kind/id columns) before running inbox-done
- Guard loop variables: skip or abort when the channel value is empty
Example fix
// before opencli slock inbox-done // after opencli slock inbox-done '#general'
Defensive patterns
Strategy: validation
Validate before calling
const channel = (process.argv[3] ?? '').trim();
if (!channel) { console.error('usage: opencli slock inbox-done <channelId|#name>'); process.exit(2); } Type guard
const isNonEmptyString = (v) => typeof v === 'string' && v.trim().length > 0;
Try / catch
try { await runInboxDone(channel); } catch (e) { if (e instanceof ArgumentError) { console.error('Missing --channel:', e.message); process.exit(2); } throw e; } Prevention
- Quote #names: opencli slock inbox-done '#general'
- Validate loop variables are non-empty before each iteration
- Look up ids from `slock inbox` output rather than typing them
When it happens
Trigger: Running `opencli slock inbox-done` with no positional channel, or with an empty value from an unset shell variable; note the channelId travels in the POST body, but it must still be supplied up front.
Common situations: Automating 'mark inbox done' across channels in a loop where one channel variable is empty; mistaking the command for one that marks everything done with no 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
- coingecko derivatives limit must be a positive integer
- --from and --to must differ (got ${fromCity})
- ${label} must be a positive integer
- ${label} must be an integer >= ${min}
- Invalid HN item id: ${args.id}
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/6097bae4d830e3e2.
Report an issue: GitHub.