jackwener/OpenCLI · error · ArgumentError
${e.message} (rethrown as ArgumentError)
Error message
${e.message} (rethrown as ArgumentError) What it means
The task-unclaim command validates the user-supplied taskId with assertMessageIdShape and rethrows any shape-validation failure as an ArgumentError, appending "(rethrown as ArgumentError)". It is a deliberate wrapper so callers can distinguish bad input shape (programmer error) from runtime/HTTP failures.
Source
Thrown at clis/slock/task-unclaim.js:32
cli({
site: SLOCK_SITE,
name: 'task-unclaim',
access: 'write',
description: 'Release ownership of a chat task (PATCH /tasks/:id/unclaim).',
domain: SLOCK_DOMAIN,
strategy: Strategy.COOKIE,
browser: true,
siteSession: 'persistent',
args: [
{ name: 'taskId', positional: true, required: true, help: 'Full task UUID (= message id; short ids rejected)' },
{ name: 'server', help: 'Override active server' },
],
columns: ['taskId', 'taskStatus', 'assigneeId', 'taskNumber'],
func: async (page, kwargs) => {
let id;
try { id = assertMessageIdShape(String(kwargs.taskId ?? '')); }
catch (e) { throw new ArgumentError(e.message); }
await page.goto(SLOCK_HOME_URL);
const snippet = `
${authHeadersFragment({ serverScoped: true, serverIdOverride: kwargs.server })}
const res = await fetch('${SLOCK_API_BASE}/tasks/' + encodeURIComponent(${JSON.stringify(id)}) + '/unclaim', { method:'PATCH', credentials:'include', headers });
if (res.status === 404) return { kind: 'http', status: 404, where: '/tasks/:id/unclaim (task not found)' };
if (res.status === 403) return { kind: 'http', status: 403, where: '/tasks/:id/unclaim (forbidden — not the assignee, terminal status, or channel archived)' };
// F6 — actionable hint for the most common reason this 409s (task already
// unclaimed, or terminal state). Bare "HTTP 409" was confusing.
if (res.status === 409) return { kind: 'http', status: 409, where: '/tasks/:id/unclaim (conflict — task is not claimed, or already in a terminal state (done/closed))' };
if (!res.ok) return { kind: res.status===401?'auth':'http', status: res.status, where:'/tasks/:id/unclaim' };
const data = await res.json().catch(() => ({}));
const t = (data && data.task) ? data.task : data;
return { kind: 'ok', rows: [t] };
`;
const result = await page.evaluate(`(async () => { ${snippet} })()`);
const rows = dispatchEvaluateResult(result);
return rows.map((t) => ({
taskId: assertTaskIdentity(t, id, 'task-unclaim'),View on GitHub (pinned to 49907e53dc)
Solutions
- Print the taskId before the call and confirm it matches the id format assertMessageIdShape requires.
- Copy the exact `taskId` column value from `task-list` rather than the task number.
- Trim/normalize the id in your script before passing it.
- Catch ArgumentError in your wrapper and print usage help.
Example fix
// before
const id = process.env.TASK_ID; // may be undefined
await cli.run(['task-unclaim', '--task-id', id]);
// after
const id = (process.env.TASK_ID ?? '').trim();
if (!id) throw new Error('TASK_ID is required');
await cli.run(['task-unclaim', '--task-id', id]); Defensive patterns
Strategy: validation
Validate before calling
const id = String(kwargs.taskId ?? '').trim();
if (!id) throw new Error('taskId is required and must match the message-id shape'); Type guard
function looksLikeMessageId(s) { return typeof s === 'string' && /^[A-Za-z0-9_-]{6,}$/.test(s.trim()); } Try / catch
try {
await cli.run(['task-unclaim', '--task-id', id]);
} catch (e) {
if (e.name === 'ArgumentError' || String(e.message).includes('rethrown as ArgumentError')) {
console.error(`bad taskId "${id}" — use the taskId column from task-list`);
} else throw e;
} Prevention
- Trim and validate ids before CLI calls
- Use taskId (not task number) from task-list
- Guard against unset env vars in scripts
When it happens
Trigger: Calling `slock task-unclaim` with a taskId that is empty, not a string-coercible id, or otherwise failing assertMessageIdShape's format rules (e.g. `--task-id ""`, whitespace, or a task number instead of a message-shaped id).
Common situations: Scripting the CLI with an unset shell variable; passing a numeric task number from task-list instead of the full taskId; trailing newline/quotes from copied ids.
Related errors
- ${e.message} (rethrown as ArgumentError)
- <train-no> "${trainNo}" does not look like a 12306 internal
- --from station must not be empty
- --to station must not be empty
- --seat-types must contain only 12306 seat letters/digits (A-
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/45d78eb9f5e7919f.
Report an issue: GitHub.