jackwener/OpenCLI · error · ArgumentError

messageId "${raw}" is not a UUID or a "#channel:shortId" for

Error message

messageId "${raw}" is not a UUID or a "#channel:shortId" form

What it means

task-convert accepts either a bare UUID or a '#channel:shortId' form; when the raw input matches neither, classifyThreadTarget returns null and an ArgumentError is thrown naming the offending input. This pre-flight validation runs before any browser/network work.

Source

Thrown at clis/slock/task-convert.js:49

  browser: true,
  siteSession: 'persistent',
  args: [
    { name: 'messageId', positional: true, required: true, help: 'Full message UUID, or "#channel:shortId" (short id expanded via /messages/context)' },
    { name: 'server', help: 'Override active server' },
  ],
  columns: ['id', 'taskNumber', 'title', 'taskStatus', 'channelId'],
  func: async (page, kwargs) => {
    const raw = String(kwargs.messageId ?? '').trim();
    if (!raw) throw new ArgumentError('messageId required');

    // Decide shape: bare UUID, or "#channel:shortId".
    let resolveFragment;
    if (UUID_RE.test(raw)) {
      resolveFragment = `const fullMsgId = ${JSON.stringify(raw)};`;
    } else {
      const tt = classifyThreadTarget(raw);
      if (!tt) {
        throw new ArgumentError(`messageId "${raw}" is not a UUID or a "#channel:shortId" form`);
      }
      const isUuid = UUID_RE.test(tt.parentTarget);
      const parent = JSON.stringify(tt.parentTarget.replace(/^#/, '').toLowerCase());
      const pmsg = JSON.stringify(tt.parentMsgId);
      // Phase 7.1 invariant baked in: we read cxd.targetMessageId, NOT
      // m.message.id. The latter is the closest-message-in-context object,
      // which can be a neighbor when the short id is just a prefix.
      resolveFragment = `
        let parentChannelId;
        if (${isUuid}) {
          parentChannelId = ${JSON.stringify(tt.parentTarget)};
        } else {
          const cres = await fetch('${SLOCK_API_BASE}/channels/', { credentials:'include', headers });
          if (!cres.ok) return { kind: cres.status===401?'auth':'http', status: cres.status, where:'/channels/' };
          const carr = await cres.json();
          const hit = (Array.isArray(carr)?carr:(carr.channels||carr.data||[])).find((c) => (c.name||c.slug||'').toLowerCase() === ${parent});
          if (!hit) return { kind: 'unresolvable', detail: 'no channel matches ' + ${parent} };
          parentChannelId = hit.id;

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Use a full message UUID, or prefix the reference as '#channel:shortId' (e.g. '#general:1234').
  2. Copy the id from the message's id column or context output rather than from a URL.
  3. Strip any surrounding markup/URL — extract just the id portion before passing it.

Example fix

// before
slock task-convert 1234
// after
slock task-convert '#general:1234'
Defensive patterns

Strategy: validation

Validate before calling

const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
const ok = UUID_RE.test(raw) || /^#[\w-]+:\d+$/.test(raw);
if (!ok) throw new Error(`messageId must be a UUID or #channel:shortId, got: ${raw}`);

Type guard

const isValidMessageRef = (v) =>
  typeof v === 'string' &&
  (/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(v) || /^#[\w-]+:\d+$/.test(v));

Try / catch

try {
  await cli('task-convert', raw);
} catch (e) {
  if (e instanceof ArgumentError && e.message.includes('not a UUID or a "#channel:shortId"')) {
    console.error('Reformat input as a UUID or #channel:shortId, e.g. #general:1234');
    process.exitCode = 2;
  } else throw e;
}

Prevention

When it happens

Trigger: Passing a short id without the '#channel:' prefix (e.g. '1234'), a URL instead of an id, a '#channel' reference missing the ':shortId' part, or arbitrary text like 'the pinned message'.

Common situations: Pasting a message permalink URL instead of the id; using the message number alone assuming it resolves; forgetting the '#channel:' prefix when only the short id is known.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/75ba662ffd0acbec. Report an issue: GitHub.