{"record":{"id":"7d1475057b71949f","repo":"jackwener/OpenCLI","slug":"messageid-required","errorCode":null,"errorMessage":"messageId required","messagePattern":"messageId required","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/slock/resolve.js","lineNumber":41,"sourceCode":"    const rest = v.slice(3);\n    if (!rest) throw new ArgumentError('dm target must be \"dm:<userId>\" or \"dm:@name\".');\n    if (UUID_RE.test(rest)) return { kind: 'dm-uuid', userId: rest };\n    if (rest.startsWith('@')) return { kind: 'dm-name', name: rest.slice(1) };\n    throw new ArgumentError('dm target must be \"dm:<userId-uuid>\" or \"dm:@name\".');\n  }\n  const tt = classifyThreadTarget(v);\n  if (tt) return { kind: 'thread', ...tt };\n  if (UUID_RE.test(v)) return { kind: 'channel-uuid', channelId: v };\n  return { kind: 'channel-name', name: v.replace(/^#/, '').toLowerCase() };\n}\n\nconst SHORT_ID_HINT =\n  'short ids (the 8-hex `msg=...` form in channel headers) are NOT accepted — use the FULL UUID ' +\n  'from `bookmark-list` / `message-read` output.';\n\nexport function assertMessageIdShape(messageId) {\n  const v = String(messageId ?? '').trim();\n  if (!v) throw new ArgumentError('messageId required');\n  if (!UUID_RE.test(v)) {\n    throw new ArgumentError(`messageId \"${v}\" is not a full UUID. ${SHORT_ID_HINT}`);\n  }\n  return v;\n}\n\nexport function parsePositiveInteger(value, name, { defaultValue, max } = {}) {\n  const raw = value === undefined || value === null || value === '' ? defaultValue : value;\n  const n = parseStrictInteger(raw);\n  if (!Number.isInteger(n) || n <= 0 || (max !== undefined && n > max)) {\n    const suffix = max !== undefined ? ` between 1 and ${max}` : ' as a positive integer';\n    throw new ArgumentError(`${name} must be${suffix} (got \"${raw}\")`);\n  }\n  return n;\n}\n\nexport function parseNonNegativeInteger(value, name, { defaultValue } = {}) {\n  const raw = value === undefined || value === null || value === '' ? defaultValue : value;","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/slock/resolve.js#L23-L59","documentation":"assertMessageIdShape throws 'messageId required' when the given messageId argument is empty after trimming (undefined, null, or ''). Every message-scoped command needs a message UUID to act on, so the empty value fails fast as an ArgumentError.","triggerScenarios":"Calling `slock reaction-add`, `reaction-remove`, or similar with --messageId omitted entirely, `--messageId=`, `--messageId \" \"`, or passing an unset variable as the id value.","commonSituations":"Automated scripts where the message id variable was never populated (e.g. message-send output not captured); optional-flag chains where --messageId was dropped; refactoring that renamed the kwarg.","solutions":["Pass a full message UUID via --messageId","Capture the messageId from `message-send` output (the 'messageId' column) into your variable","Check the flag spelling so kwargs.messageId isn't falling back to '' via `?? ''`"],"exampleFix":"// before\nconst id = process.env.MSG_ID; // unset\nawait cli('reaction-add', { messageId: id ?? '', emoji: '👍' });\n// after\nconst id = process.env.MSG_ID;\nif (!id) throw new Error('MSG_ID env var must contain a message UUID');\nawait cli('reaction-add', { messageId: id, emoji: '👍' });","handlingStrategy":"validation","validationCode":"if (!String(messageId ?? '').trim()) throw new Error('messageId required: pass --messageId <full-uuid>');","typeGuard":"function hasMessageId(v) {\n  return typeof v === 'string' && v.trim().length > 0;\n}","tryCatchPattern":"try {\n  await cli('reaction-add', { messageId, emoji });\n} catch (e) {\n  if (e instanceof ArgumentError && e.message === 'messageId required') {\n    console.error('--messageId was empty; check the variable/flag supplying it (must be a full UUID).');\n  } else throw e;\n}","preventionTips":["Capture the messageId column from message-send output immediately and check it is non-empty","Check flag spelling (--messageId) so kwargs fallbacks to '' are avoided","Fail fast in scripts when id variables are unset","Prefer passing ids explicitly over positional/env indirection"],"tags":["argument-validation","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"}