{"record":{"id":"29ec1b24389d759c","repo":"jackwener/OpenCLI","slug":"channel-required-29ec1b","errorCode":null,"errorMessage":"channel required","messagePattern":"channel required","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/slock/task-get.js","lineNumber":33,"sourceCode":"\ncli({\n  site: SLOCK_SITE,\n  name: 'task-get',\n  access: 'read',\n  description: 'Fetch a task by channel + taskNumber (GET /tasks/channel/:channelId/number/:taskNumber).',\n  domain: SLOCK_DOMAIN,\n  strategy: Strategy.COOKIE,\n  browser: true,\n  siteSession: 'persistent',\n  args: [\n    { name: 'channel', positional: true, required: true, help: 'channelId UUID or #name' },\n    { name: 'number', positional: true, required: true, help: 'taskNumber (per-channel integer, as shown in \"task #N\")' },\n    { name: 'server', help: 'Override active server' },\n  ],\n  columns: ['id', 'taskNumber', 'title', 'taskStatus', 'assigneeId'],\n  func: async (page, kwargs) => {\n    const channel = String(kwargs.channel ?? '').trim();\n    if (!channel) throw new ArgumentError('channel required');\n    const numRaw = String(kwargs.number ?? '').trim();\n    if (!/^\\d+$/.test(numRaw)) throw new ArgumentError(`number \"${numRaw}\" is not a positive integer`);\n    const number = parsePositiveInteger(numRaw, 'number');\n    await page.goto(SLOCK_HOME_URL);\n    const snippet = `\n      ${authHeadersFragment({ serverScoped: true, serverIdOverride: kwargs.server })}\n      ${channelResolveFragment(channel)}\n      const res = await fetch('${SLOCK_API_BASE}/tasks/channel/' + encodeURIComponent(channelId) + '/number/' + encodeURIComponent(${JSON.stringify(String(number))}), { credentials:'include', headers });\n      if (res.status === 404) return { kind: 'http', status: 404, where: '/tasks/channel/:id/number/:n (task #' + ${JSON.stringify(number)} + ' not found in channel)' };\n      if (!res.ok) return { kind: res.status===401?'auth':'http', status: res.status, where:'/tasks/channel/:id/number/:n' };\n      const data = await res.json().catch(() => ({}));\n      // Single object or {task: ...} wrapped — accept either.\n      const task = data && data.task ? data.task : data;\n      return { kind: 'ok', rows: [task] };\n    `;\n    const result = await page.evaluate(`(async () => { ${snippet} })()`);\n    const rows = dispatchEvaluateResult(result);\n    return rows.map((t) => ({","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/slock/task-get.js#L15-L51","documentation":"task-get requires a `channel` option; the func trims it and throws ArgumentError when empty, before validating the task number. The channel is needed to resolve the per-channel taskNumber via channelResolveFragment.","triggerScenarios":"Running task-get without --channel, or with --channel set to empty/whitespace.","commonSituations":"Omitting the flag in scripts that assume a default channel exists; env/config variable for the channel unset; copying an example command that used a placeholder channel.","solutions":["Pass --channel with the target channel, e.g. --channel general.","Verify the variable/config supplying the channel name is populated.","If unsure of the channel slug, list channels first and use the exact slug."],"exampleFix":"// before\nslock task-get \"$CHANNEL\" 5   # CHANNEL empty\n// after\nslock task-get --channel general --number 5","handlingStrategy":"validation","validationCode":"const channel = String(opts.channel ?? '').trim();\nif (!channel) throw new Error('channel is required for task-get');\nif (!/^\\d+$/.test(number)) throw new Error(`number must be a positive integer, got: ${number}`);","typeGuard":"const hasChannel = (v) => typeof v === 'string' && v.trim().length > 0;","tryCatchPattern":"try {\n  await cli('task-get', ['--channel', channel, '--number', String(number)]);\n} catch (e) {\n  if (e instanceof ArgumentError && e.message === 'channel required') {\n    console.error('Pass --channel <slug> along with --number.');\n    process.exitCode = 2;\n  } else throw e;\n}","preventionTips":["Always pass the channel alongside the per-channel taskNumber.","Check the channel variable is populated in scripts (${CHANNEL:?msg}).","Verify the channel slug against the channel list to avoid downstream resolution failures."],"tags":["cli","missing-argument","input-validation"],"backgroundTag":"missing-required-argument","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}