{"record":{"id":"b80f04893e723196","repo":"jackwener/OpenCLI","slug":"e-message-rethrown-from-assertmessageidshape-b80f04","errorCode":null,"errorMessage":"${e.message} (rethrown from assertMessageIdShape; e.g. taskId is not a full UUID)","messagePattern":"(.+?) \\(rethrown from assertMessageIdShape; e\\.g\\. taskId is not a full UUID\\)","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/slock/task-delete.js","lineNumber":35,"sourceCode":"cli({\n  site: SLOCK_SITE,\n  name: 'task-delete',\n  access: 'write',\n  description: 'Delete a chat task (DELETE /tasks/:taskId). Requires --confirm — destructive, irreversible.',\n  domain: SLOCK_DOMAIN,\n  strategy: Strategy.COOKIE,\n  browser: true,\n  siteSession: 'persistent',\n  args: [\n    { name: 'taskId', positional: true, required: true, help: 'Full task UUID (= message id; short ids rejected)' },\n    { name: 'confirm', type: 'bool', default: false, help: 'Required acknowledgement: deletion is irreversible' },\n    { name: 'server', help: 'Override active server' },\n  ],\n  columns: ['taskId', 'deleted'],\n  func: async (page, kwargs) => {\n    let id;\n    try { id = assertMessageIdShape(String(kwargs.taskId ?? '')); }\n    catch (e) { throw new ArgumentError(e.message); }\n    if (!kwargs.confirm) {\n      // No network touched without --confirm. Return a planned-action row\n      // so users know the call was a no-op and what to do next.\n      return [{ taskId: id, deleted: false, note: 'no-op: pass --confirm to actually delete (irreversible)' }];\n    }\n    await page.goto(SLOCK_HOME_URL);\n    const snippet = `\n      ${authHeadersFragment({ serverScoped: true, serverIdOverride: kwargs.server })}\n      const res = await fetch('${SLOCK_API_BASE}/tasks/' + encodeURIComponent(${JSON.stringify(id)}), { method:'DELETE', credentials:'include', headers });\n      if (res.status === 403) return { kind: 'http', status: 403, where: '/tasks/:taskId (forbidden — not the owner/admin or channel archived)' };\n      if (res.status === 404) return { kind: 'http', status: 404, where: '/tasks/:taskId (task not found)' };\n      if (!res.ok) return { kind: res.status===401?'auth':'http', status: res.status, where:'/tasks/:taskId' };\n      // 204 No Content is common for DELETE; tolerate empty body.\n      return { kind: 'ok', rows: [{ taskId: ${JSON.stringify(id)}, deleted: true }] };\n    `;\n    const result = await page.evaluate(`(async () => { ${snippet} })()`);\n    const rows = dispatchEvaluateResult(result);\n    return rows.map((r) => ({ taskId: r.taskId ?? id, deleted: r.deleted ?? true }));","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/slock/task-delete.js#L17-L53","documentation":"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.","triggerScenarios":"Calling task-delete with an empty taskId, a short task number ('42') instead of the UUID, a '#channel:shortId' string, or a truncated UUID.","commonSituations":"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.","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."],"exampleFix":"// before\nslock task-delete 42 --confirm\n// after\nslock task-delete 9f3c1a2e-4b5d-4c6e-8f70-1a2b3c4d5e6f --confirm","handlingStrategy":"validation","validationCode":"const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\nif (!UUID_RE.test(taskId)) throw new Error(`taskId must be a full UUID, got: ${taskId}`);\nif (!confirm) console.warn('dry-run: add --confirm to actually delete');","typeGuard":"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);","tryCatchPattern":"try {\n  await cli('task-delete', [taskId, '--confirm']);\n} catch (e) {\n  if (e instanceof ArgumentError && e.message.includes('assertMessageIdShape')) {\n    console.error('Resolve the task UUID via task-get before deleting.');\n    process.exitCode = 2;\n  } else throw e;\n}","preventionTips":["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."],"tags":["cli","uuid","argument-validation"],"backgroundTag":"invalid-uuid-format","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}