{"record":{"id":"e4149e45e8661f91","repo":"jackwener/OpenCLI","slug":"target-required","errorCode":null,"errorMessage":"target required","messagePattern":"target required","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/slock/message-send.js","lineNumber":29,"sourceCode":"  name: 'message-send',\n  access: 'write',\n  description: 'Send a message to a channel, DM, or thread (content sent verbatim)',\n  domain: SLOCK_DOMAIN,\n  strategy: Strategy.COOKIE,\n  browser: true,\n  siteSession: 'persistent',\n  args: [\n    { name: 'target', positional: true, required: true, help: '\"#channel\", \"#channel:msgIdOrShort\", \"dm:@name\", \"dm:<uuid>\", or channel UUID' },\n    { name: 'content', positional: true, required: true, help: 'Message body (sent verbatim, no marker)' },\n    { name: 'dry-run', type: 'bool', default: false, help: 'Print the planned payload without sending' },\n    { name: 'as-task', type: 'bool', default: false, help: 'Create the message as a task (asTask)' },\n    { name: 'attach', help: 'Comma-separated attachmentId UUIDs (upload separately first)' },\n    { name: 'server', help: 'Override active server (slug or id)' },\n  ],\n  columns: ['target', 'channelId', 'content', 'result', 'messageId'],\n  func: async (page, kwargs) => {\n    const target = String(kwargs.target ?? '').trim();\n    if (!target) throw new ArgumentError('target required');\n    const content = String(kwargs.content ?? '');\n    const asTask = !!kwargs['as-task'];\n    const attachmentIds = String(kwargs.attach ?? '')\n      .split(',').map((s) => s.trim()).filter(Boolean);\n    for (const aid of attachmentIds) {\n      if (!UUID_RE.test(aid)) throw new ArgumentError(`--attach expects attachmentId UUIDs; \"${aid}\" is not a UUID`);\n    }\n    let cls;\n    try { cls = classifyTarget(target); }\n    catch (e) { throw new ArgumentError(e.message); }\n\n    const extra = { asTask, attachmentIds };\n\n    if (kwargs['dry-run']) {\n      return [{\n        target, channelId: '(not resolved in dry-run)', content,\n        result: asTask ? 'dry-run (asTask)' : 'dry-run', messageId: null,\n      }];","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/slock/message-send.js#L11-L47","documentation":"message-send.js requires a `target` argument identifying the destination (channel, DM, etc.). If the kwarg is missing or trims to empty, it throws ArgumentError('target required').","triggerScenarios":"Calling message-send without `--target`, or with `--target \"\"`/whitespace.","commonSituations":"Omitting the flag in an automated send; a variable holding the destination is undefined; quoting problems losing the argument.","solutions":["Pass a target: `--target #general`, a channel UUID, or a DM target form.","Ensure the value sourcing the flag is defined and non-empty.","Check shell quoting so the argument reaches the command."],"exampleFix":"// before\nawait run('message-send', { content: 'hello' });\n// after\nawait run('message-send', { target: '#general', content: 'hello' });","handlingStrategy":"validation","validationCode":"const target = String(kwargs.target ?? '').trim();\nif (!target) throw new Error('message-send: --target is required');","typeGuard":"const target = typeof kwargs.target === 'string' && kwargs.target.trim() ? kwargs.target.trim() : null;\nif (!target) throw new Error('target required');","tryCatchPattern":"try { await sendMessage(page, kwargs); } catch (e) { if (e instanceof ArgumentError && e.message === 'target required') { console.error('Usage: message-send --target <#slug|uuid|dm> --content \"...\"'); } else throw e; }","preventionTips":["Always include --target in send scripts","Store default target channel in config and assert non-empty","Validate kwargs before dispatching"],"tags":["missing-argument","cli","validation"],"backgroundTag":"missing-required-argument","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}