jackwener/OpenCLI · error · ArgumentError

--after must be a seq number or messageId UUID (got "${after

Error message

--after must be a seq number or messageId UUID (got "${after}")

What it means

message-read.js validates the optional `--after` cursor: it must be either a numeric sequence number (/^\d+$/) or a messageId UUID (UUID_RE). Any other non-empty value throws this ArgumentError naming the offending value.

Source

Thrown at clis/slock/message-read.js:50

  browser: true,
  siteSession: 'persistent',
  args: [
    { name: 'channel', positional: true, required: true, help: 'channelId UUID, "#name", or "#channel:msgIdOrShort"' },
    { name: 'after', help: 'Cursor: seq number or messageId UUID (exclusive)' },
    { name: 'before', help: 'seq to page before' },
    { name: 'limit', type: 'int', default: 50, help: 'Max messages' },
    { name: 'no-threads', type: 'bool', default: false, help: 'Skip /threads enrichment' },
    { name: 'server', help: 'Override active server' },
  ],
  columns: ['id', 'seq', 'createdAt', 'senderName', 'content', 'threadChannelId', 'replyCount', 'unreadCount', 'lastReplyAt'],
  func: async (page, kwargs) => {
    const channel = String(kwargs.channel ?? '').trim();
    if (!channel) throw new ArgumentError('channel required');
    const tt = classifyThreadTarget(channel);
    const isUuid = UUID_RE.test(channel);
    const after = kwargs.after !== undefined ? String(kwargs.after) : '';
    if (after && !/^\d+$/.test(after) && !UUID_RE.test(after)) {
      throw new ArgumentError(`--after must be a seq number or messageId UUID (got "${after}")`);
    }
    const limit = parsePositiveInteger(kwargs.limit, '--limit', { defaultValue: 50 });
    const before = kwargs.before !== undefined ? String(kwargs.before) : '';
    if (before && !/^\d+$/.test(before)) {
      throw new ArgumentError(`--before must be a seq number (got "${before}")`);
    }
    if (before) parsePositiveInteger(before, '--before');
    const noThreads = !!kwargs['no-threads'];
    // R1 — pass the raw override through to authHeadersFragment; it owns the
    // UUID-vs-slug resolution against /servers/ now.
    const override = kwargs.server ?? null;

    await page.goto(SLOCK_HOME_URL);

    const params = {
      isUuid, channel, after, before, limit, noThreads, override,
      parentTarget: tt?.parentTarget ?? '',
      parentMsgId: tt?.parentMsgId ?? '',

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Use the numeric message `seq` value or the full messageId UUID for --after.
  2. If you have a timestamp, first fetch messages and use the closest seq/UUID as the cursor.
  3. Strip stray whitespace/characters from the value before passing it.

Example fix

// before
--after 2026-08-29T10:00:00Z
// after
--after 8471   (or --after 6f1c2e34-9a0b-4c8d-8e2f-1a2b3c4d5e6f)
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;
if (after != null && after !== '' && !/^\d+$/.test(String(after)) && !UUID_RE.test(String(after))) throw new Error(`--after must be a seq number or UUID, got: ${after}`);

Type guard

const isValidAfter = (v) => v === undefined || v === '' || /^\d+$/.test(String(v)) || /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(String(v));

Try / catch

try { await readMessages(page, {...kwargs, after}); } catch (e) { if (String(e.message).startsWith('--after must be')) { console.error(`Bad --after cursor "${after}"; use seq number or messageId UUID`); } else throw e; }

Prevention

When it happens

Trigger: Passing `--after` with a timestamp string, a non-UUID message id (slug/base64), a float like "1.5", or a seq with units ("12s").

Common situations: Using a createdAt ISO timestamp as a cursor; copying a message URL slug instead of the message UUID; locale-formatted numbers.

Related errors


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