{"record":{"id":"0aee1703fc2f287f","repo":"jackwener/OpenCLI","slug":"channel-required-0aee17","errorCode":null,"errorMessage":"channel required","messagePattern":"channel required","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/slock/task-create.js","lineNumber":42,"sourceCode":"cli({\n  site: SLOCK_SITE,\n  name: 'task-create',\n  access: 'write',\n  description: 'Create a task in a channel (single title; batch 1-50 is server-supported but client surface is single — see backlog R4).',\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: 'title', positional: true, required: true, help: 'Task title (single; batch TODO via R4)' },\n    { name: 'desc', help: 'Optional description body for the task' },\n    { name: 'server', help: 'Override active server' },\n  ],\n  columns: ['id', 'taskNumber', 'title', 'taskStatus', 'channelId'],\n  func: async (page, kwargs) => {\n    const channel = String(kwargs.channel ?? '').trim();\n    if (!channel) throw new ArgumentError('channel required');\n    const title = String(kwargs.title ?? '').trim();\n    if (!title) throw new ArgumentError('title required (non-empty)');\n    const desc = kwargs.desc != null ? String(kwargs.desc) : '';\n    await page.goto(SLOCK_HOME_URL);\n    const taskObj = desc ? { title, description: desc } : { title };\n    const snippet = `\n      ${authHeadersFragment({ serverScoped: true, serverIdOverride: kwargs.server })}\n      ${channelResolveFragment(channel)}\n      // Body is always a batch array — N=1 here because the CLI exposes one\n      // title at a time (R4 will widen this). Keep the wrapper so the server\n      // sees the same shape as a real batch and we don't fork the contract.\n      const body = { tasks: [${JSON.stringify(taskObj)}] };\n      const res = await fetch('${SLOCK_API_BASE}/tasks/channel/' + encodeURIComponent(channelId), {\n        method:'POST', credentials:'include', headers, body: JSON.stringify(body),\n      });\n      if (res.status === 400) {\n        const j = await res.json().catch(() => ({}));\n        return { kind: 'http', status: 400, where: '/tasks/channel/:id (bad request: ' + (j.error || j.message || 'title/limit/shape') + ')' };","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/slock/task-create.js#L24-L60","documentation":"task-create requires a `channel` option identifying the target channel; the func trims the value and throws ArgumentError when it is empty. The channel is resolved later via channelResolveFragment, but emptiness is rejected up front.","triggerScenarios":"Running task-create without --channel, or with --channel set to an empty/whitespace string.","commonSituations":"Forgetting the flag in an alias or wrapper script; a config file missing the channel key so the interpolated value is empty; renaming a channel in config but leaving the variable unset.","solutions":["Pass --channel with the channel name/slug, e.g. --channel general.","Check wrapper scripts/aliases actually forward the --channel flag.","Verify the config or env value supplying the channel is populated."],"exampleFix":"// before\nslock task-create --title \"Fix bug\"\n// after\nslock task-create --channel general --title \"Fix bug\"","handlingStrategy":"validation","validationCode":"const channel = String(opts.channel ?? '').trim();\nif (!channel) throw new Error('channel is required for task-create');","typeGuard":"const hasChannel = (v) => typeof v === 'string' && v.trim().length > 0;","tryCatchPattern":"try {\n  await cli('task-create', ['--channel', channel, '--title', title]);\n} catch (e) {\n  if (e instanceof ArgumentError && e.message === 'channel required') {\n    console.error('Pass --channel <slug>; see channel list for valid slugs.');\n    process.exitCode = 2;\n  } else throw e;\n}","preventionTips":["Default the channel in wrapper scripts from config, but fail loudly when unset.","Validate the channel slug against the channel list before creating tasks.","Quote flag values and check ${CHANNEL:?msg} in shell scripts."],"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"}