{"record":{"id":"6097bae4d830e3e2","repo":"jackwener/OpenCLI","slug":"channel-required-6097ba","errorCode":null,"errorMessage":"channel required","messagePattern":"channel required","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/slock/inbox-done.js","lineNumber":24,"sourceCode":"import { SLOCK_SITE, SLOCK_DOMAIN, SLOCK_HOME_URL, SLOCK_API_BASE } from './shared.js';\n\ncli({\n  site: SLOCK_SITE,\n  name: 'inbox-done',\n  access: 'write',\n  description: 'Mark one chat as done / clear it from the inbox (POST /channels/inbox/done)',\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: 'server', help: 'Override active server' },\n  ],\n  columns: ['channel', 'result'],\n  func: async (page, kwargs) => {\n    const channel = String(kwargs.channel ?? '').trim();\n    if (!channel) throw new ArgumentError('channel required');\n    await page.goto(SLOCK_HOME_URL);\n    // channelId travels in the BODY (not the URL), so resolve then POST the fixed path.\n    const snippet = `\n      ${authHeadersFragment({ serverScoped: true, serverIdOverride: kwargs.server })}\n      ${channelResolveFragment(channel)}\n      const res = await fetch('${SLOCK_API_BASE}/channels/inbox/done', { method:'POST', credentials:'include', headers, body: JSON.stringify({ channelId }) });\n      if (res.status === 401) return { kind: 'auth', detail: '/channels/inbox/done returned 401' };\n      if (!res.ok) return { kind: 'http', status: res.status, where:'/channels/inbox/done' };\n      const data = await res.json().catch(() => ({}));\n      return { kind: 'ok', rows: data };\n    `;\n    const result = await page.evaluate(`(async () => { ${snippet} })()`);\n    dispatchEvaluateResult(result);\n    return [{ channel, result: 'done' }];\n  },\n});\n","sourceCodeStart":6,"sourceCodeEnd":41,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/slock/inbox-done.js#L6-L41","documentation":"The slock inbox-done command requires a channel argument (channelId UUID or #name). Like channel-members, it throws ArgumentError when the positional --channel value is missing or blank. The fail-fast guard runs before page navigation and the POST to /channels/inbox/done.","triggerScenarios":"Running `opencli slock inbox-done` with no positional channel, or with an empty value from an unset shell variable; note the channelId travels in the POST body, but it must still be supplied up front.","commonSituations":"Automating 'mark inbox done' across channels in a loop where one channel variable is empty; mistaking the command for one that marks everything done with no argument.","solutions":["Provide the channel: `opencli slock inbox-done '#general'` or with a UUID","Get a valid id via `opencli slock inbox` (the kind/id columns) before running inbox-done","Guard loop variables: skip or abort when the channel value is empty"],"exampleFix":"// before\nopencli slock inbox-done\n// after\nopencli slock inbox-done '#general'","handlingStrategy":"validation","validationCode":"const channel = (process.argv[3] ?? '').trim();\nif (!channel) { console.error('usage: opencli slock inbox-done <channelId|#name>'); process.exit(2); }","typeGuard":"const isNonEmptyString = (v) => typeof v === 'string' && v.trim().length > 0;","tryCatchPattern":"try { await runInboxDone(channel); } catch (e) { if (e instanceof ArgumentError) { console.error('Missing --channel:', e.message); process.exit(2); } throw e; }","preventionTips":["Quote #names: opencli slock inbox-done '#general'","Validate loop variables are non-empty before each iteration","Look up ids from `slock inbox` output rather than typing them"],"tags":["cli","argument-error","input-validation"],"backgroundTag":"missing-required-argument","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}