jackwener/OpenCLI · error · ArgumentError
messageId required
Error message
messageId required
What it means
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.
Source
Thrown at clis/slock/resolve.js:41
const rest = v.slice(3);
if (!rest) throw new ArgumentError('dm target must be "dm:<userId>" or "dm:@name".');
if (UUID_RE.test(rest)) return { kind: 'dm-uuid', userId: rest };
if (rest.startsWith('@')) return { kind: 'dm-name', name: rest.slice(1) };
throw new ArgumentError('dm target must be "dm:<userId-uuid>" or "dm:@name".');
}
const tt = classifyThreadTarget(v);
if (tt) return { kind: 'thread', ...tt };
if (UUID_RE.test(v)) return { kind: 'channel-uuid', channelId: v };
return { kind: 'channel-name', name: v.replace(/^#/, '').toLowerCase() };
}
const SHORT_ID_HINT =
'short ids (the 8-hex `msg=...` form in channel headers) are NOT accepted — use the FULL UUID ' +
'from `bookmark-list` / `message-read` output.';
export function assertMessageIdShape(messageId) {
const v = String(messageId ?? '').trim();
if (!v) throw new ArgumentError('messageId required');
if (!UUID_RE.test(v)) {
throw new ArgumentError(`messageId "${v}" is not a full UUID. ${SHORT_ID_HINT}`);
}
return v;
}
export function parsePositiveInteger(value, name, { defaultValue, max } = {}) {
const raw = value === undefined || value === null || value === '' ? defaultValue : value;
const n = parseStrictInteger(raw);
if (!Number.isInteger(n) || n <= 0 || (max !== undefined && n > max)) {
const suffix = max !== undefined ? ` between 1 and ${max}` : ' as a positive integer';
throw new ArgumentError(`${name} must be${suffix} (got "${raw}")`);
}
return n;
}
export function parseNonNegativeInteger(value, name, { defaultValue } = {}) {
const raw = value === undefined || value === null || value === '' ? defaultValue : value;View on GitHub (pinned to 49907e53dc)
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 `?? ''`
Example fix
// before
const id = process.env.MSG_ID; // unset
await cli('reaction-add', { messageId: id ?? '', emoji: '👍' });
// after
const id = process.env.MSG_ID;
if (!id) throw new Error('MSG_ID env var must contain a message UUID');
await cli('reaction-add', { messageId: id, emoji: '👍' }); Defensive patterns
Strategy: validation
Validate before calling
if (!String(messageId ?? '').trim()) throw new Error('messageId required: pass --messageId <full-uuid>'); Type guard
function hasMessageId(v) {
return typeof v === 'string' && v.trim().length > 0;
} Try / catch
try {
await cli('reaction-add', { messageId, emoji });
} catch (e) {
if (e instanceof ArgumentError && e.message === 'messageId required') {
console.error('--messageId was empty; check the variable/flag supplying it (must be a full UUID).');
} else throw e;
} Prevention
- 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
When it happens
Trigger: Calling `slock reaction-add`, `reaction-remove`, or similar with --messageId omitted entirely, `--messageId=`, `--messageId " "`, or passing an unset variable as the id value.
Common situations: 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.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- archive wayback url cannot be empty
- designer is required (for example: halolab)
- shot is required (numeric id or dribbble.com/shots URL)
- query is required
- emoji required (a single unicode emoji)
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/7d1475057b71949f.
Report an issue: GitHub.