jackwener/OpenCLI · error · ArgumentError
${e.message} (rethrown from assertMessageIdShape; e.g. taskI
Error message
${e.message} (rethrown from assertMessageIdShape; e.g. taskId is not a full UUID) What it means
task-delete validates its taskId with assertMessageIdShape and rethrows failures as an ArgumentError noting the rethrow origin and that taskId must be a full UUID. Validation happens before the --confirm guard, so malformed ids never reach the network.
Source
Thrown at clis/slock/task-delete.js:35
cli({
site: SLOCK_SITE,
name: 'task-delete',
access: 'write',
description: 'Delete a chat task (DELETE /tasks/:taskId). Requires --confirm — destructive, irreversible.',
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: 'confirm', type: 'bool', default: false, help: 'Required acknowledgement: deletion is irreversible' },
{ name: 'server', help: 'Override active server' },
],
columns: ['taskId', 'deleted'],
func: async (page, kwargs) => {
let id;
try { id = assertMessageIdShape(String(kwargs.taskId ?? '')); }
catch (e) { throw new ArgumentError(e.message); }
if (!kwargs.confirm) {
// No network touched without --confirm. Return a planned-action row
// so users know the call was a no-op and what to do next.
return [{ taskId: id, deleted: false, note: 'no-op: pass --confirm to actually delete (irreversible)' }];
}
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)}), { method:'DELETE', credentials:'include', headers });
if (res.status === 403) return { kind: 'http', status: 403, where: '/tasks/:taskId (forbidden — not the owner/admin or channel archived)' };
if (res.status === 404) return { kind: 'http', status: 404, where: '/tasks/:taskId (task not found)' };
if (!res.ok) return { kind: res.status===401?'auth':'http', status: res.status, where:'/tasks/:taskId' };
// 204 No Content is common for DELETE; tolerate empty body.
return { kind: 'ok', rows: [{ taskId: ${JSON.stringify(id)}, deleted: true }] };
`;
const result = await page.evaluate(`(async () => { ${snippet} })()`);
const rows = dispatchEvaluateResult(result);
return rows.map((r) => ({ taskId: r.taskId ?? id, deleted: r.deleted ?? true }));View on GitHub (pinned to 49907e53dc)
Solutions
- Pass the full task UUID from the taskId column of task-list output.
- Look up the UUID via task-get (channel + number) when only the number is known.
- Read the inner e.message before the 'rethrown' suffix for the specific shape problem.
Example fix
// before slock task-delete 42 --confirm // after slock task-delete 9f3c1a2e-4b5d-4c6e-8f70-1a2b3c4d5e6f --confirm
Defensive patterns
Strategy: validation
Validate before calling
const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
if (!UUID_RE.test(taskId)) throw new Error(`taskId must be a full UUID, got: ${taskId}`);
if (!confirm) console.warn('dry-run: add --confirm to actually delete'); Type guard
const isUuid = (v) => typeof v === 'string' && /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(v); Try / catch
try {
await cli('task-delete', [taskId, '--confirm']);
} catch (e) {
if (e instanceof ArgumentError && e.message.includes('assertMessageIdShape')) {
console.error('Resolve the task UUID via task-get before deleting.');
process.exitCode = 2;
} else throw e;
} Prevention
- Store and pass full UUIDs, never display task numbers.
- Regex-validate id shape before destructive commands.
- Combine with --confirm checks in wrappers to avoid both bad ids and accidental deletes.
When it happens
Trigger: Calling task-delete with an empty taskId, a short task number ('42') instead of the UUID, a '#channel:shortId' string, or a truncated UUID.
Common situations: Using the display taskNumber from 'task #N' rather than the taskId column; storing ids in spreadsheets that trimmed the UUID; mixing message ids with task ids.
Related errors
- id not a valid Grok session ID (got "${input}"); expected a
- ${e.message} (rethrown from assertMessageIdShape; e.g. taskI
- <train-no> "${trainNo}" does not look like a 12306 internal
- --from station must not be empty
- --to station must not be empty
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/b80f04893e723196.
Report an issue: GitHub.