jackwener/OpenCLI · error · ArgumentError
number "${numRaw}" is not a positive integer
Error message
number "${numRaw}" is not a positive integer What it means
The slock task-get CLI command validates the --number argument with a strict /^\d+$/ digit-only regex before parsing it via parsePositiveInteger. If the value contains any non-digit character (or is empty), it throws an ArgumentError immediately, before any page navigation or network call. This fail-fast check prevents building an invalid API URL.
Source
Thrown at clis/slock/task-get.js:35
site: SLOCK_SITE,
name: 'task-get',
access: 'read',
description: 'Fetch a task by channel + taskNumber (GET /tasks/channel/:channelId/number/:taskNumber).',
domain: SLOCK_DOMAIN,
strategy: Strategy.COOKIE,
browser: true,
siteSession: 'persistent',
args: [
{ name: 'channel', positional: true, required: true, help: 'channelId UUID or #name' },
{ name: 'number', positional: true, required: true, help: 'taskNumber (per-channel integer, as shown in "task #N")' },
{ name: 'server', help: 'Override active server' },
],
columns: ['id', 'taskNumber', 'title', 'taskStatus', 'assigneeId'],
func: async (page, kwargs) => {
const channel = String(kwargs.channel ?? '').trim();
if (!channel) throw new ArgumentError('channel required');
const numRaw = String(kwargs.number ?? '').trim();
if (!/^\d+$/.test(numRaw)) throw new ArgumentError(`number "${numRaw}" is not a positive integer`);
const number = parsePositiveInteger(numRaw, 'number');
await page.goto(SLOCK_HOME_URL);
const snippet = `
${authHeadersFragment({ serverScoped: true, serverIdOverride: kwargs.server })}
${channelResolveFragment(channel)}
const res = await fetch('${SLOCK_API_BASE}/tasks/channel/' + encodeURIComponent(channelId) + '/number/' + encodeURIComponent(${JSON.stringify(String(number))}), { credentials:'include', headers });
if (res.status === 404) return { kind: 'http', status: 404, where: '/tasks/channel/:id/number/:n (task #' + ${JSON.stringify(number)} + ' not found in channel)' };
if (!res.ok) return { kind: res.status===401?'auth':'http', status: res.status, where:'/tasks/channel/:id/number/:n' };
const data = await res.json().catch(() => ({}));
// Single object or {task: ...} wrapped — accept either.
const task = data && data.task ? data.task : data;
return { kind: 'ok', rows: [task] };
`;
const result = await page.evaluate(`(async () => { ${snippet} })()`);
const rows = dispatchEvaluateResult(result);
return rows.map((t) => ({
id: t.id ?? '',
taskNumber: t.taskNumber ?? number,View on GitHub (pinned to 49907e53dc)
Solutions
- Pass only digits as --number, e.g. --number 42
- If you have a task key/uuid, use the command that looks tasks up by id instead of by number
- Strip non-digit characters from the input before invoking (e.g. num=${TSK-12//[!0-9]/} in bash)
- Verify the variable you interpolate is non-empty: [ -n "$NUM" ] || exit 1
Example fix
// before
await cli('slock', 'task-get', '--channel', 'general', '--number', 'TSK-12');
// after
await cli('slock', 'task-get', '--channel', 'general', '--number', '12'); Defensive patterns
Strategy: validation
Validate before calling
const numRaw = String(number ?? '').trim();
if (!/^\d+$/.test(numRaw)) {
throw new Error(`--number must be digits-only, got: "${numRaw}"`);
} Type guard
const isPositiveIntString = (v) => typeof v === 'string' && /^\d+$/.test(v.trim());
Prevention
- Always pass the bare numeric taskNumber, never a prefixed key like TSK-12
- Trim and sanitize shell variables before interpolating into CLI args
- Guard for empty/unset variables before invoking the command
When it happens
Trigger: Running `slock task-get --channel <ch> --number <value>` where value is empty, contains letters, signs, decimals, spaces, or other non-digits, e.g. --number 12a, --number -1, --number 3.5, --number ''.
Common situations: Typing a task key like 'TSK-12' instead of the bare number; pasting a value with trailing whitespace or invisible characters; passing a shell variable that is unset/empty; confusion between task id (uuid) and taskNumber (integer).
Related errors
- ${label} must be <= ${maxValue}
- ${label} must be a positive integer
- ${label} must be >= ${min}
- archive snapshots url cannot be empty
- archive snapshots limit must be a positive integer
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/781eceabb39effc0.
Report an issue: GitHub.