{"record":{"id":"4800e0e81e76a3f1","repo":"jackwener/OpenCLI","slug":"before-must-be-a-seq-number-got-before","errorCode":null,"errorMessage":"--before must be a seq number (got \"${before}\")","messagePattern":"--before must be a seq number \\(got \"(.+?)\"\\)","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/slock/message-read.js","lineNumber":55,"sourceCode":"    { name: 'before', help: 'seq to page before' },\n    { name: 'limit', type: 'int', default: 50, help: 'Max messages' },\n    { name: 'no-threads', type: 'bool', default: false, help: 'Skip /threads enrichment' },\n    { name: 'server', help: 'Override active server' },\n  ],\n  columns: ['id', 'seq', 'createdAt', 'senderName', 'content', 'threadChannelId', 'replyCount', 'unreadCount', 'lastReplyAt'],\n  func: async (page, kwargs) => {\n    const channel = String(kwargs.channel ?? '').trim();\n    if (!channel) throw new ArgumentError('channel required');\n    const tt = classifyThreadTarget(channel);\n    const isUuid = UUID_RE.test(channel);\n    const after = kwargs.after !== undefined ? String(kwargs.after) : '';\n    if (after && !/^\\d+$/.test(after) && !UUID_RE.test(after)) {\n      throw new ArgumentError(`--after must be a seq number or messageId UUID (got \"${after}\")`);\n    }\n    const limit = parsePositiveInteger(kwargs.limit, '--limit', { defaultValue: 50 });\n    const before = kwargs.before !== undefined ? String(kwargs.before) : '';\n    if (before && !/^\\d+$/.test(before)) {\n      throw new ArgumentError(`--before must be a seq number (got \"${before}\")`);\n    }\n    if (before) parsePositiveInteger(before, '--before');\n    const noThreads = !!kwargs['no-threads'];\n    // R1 — pass the raw override through to authHeadersFragment; it owns the\n    // UUID-vs-slug resolution against /servers/ now.\n    const override = kwargs.server ?? null;\n\n    await page.goto(SLOCK_HOME_URL);\n\n    const params = {\n      isUuid, channel, after, before, limit, noThreads, override,\n      parentTarget: tt?.parentTarget ?? '',\n      parentMsgId: tt?.parentMsgId ?? '',\n      isThread: !!tt,\n    };\n    const snippet = buildReadSnippet(params);\n    const result = await page.evaluate(`(async () => { ${snippet} })()`);\n","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/slock/message-read.js#L37-L73","documentation":"message-read.js validates the optional `--before` cursor: unlike --after it accepts only numeric sequence numbers (no UUIDs). A non-empty value that isn't all digits throws this ArgumentError.","triggerScenarios":"Passing `--before` with a UUID, timestamp, or any non-numeric string.","commonSituations":"Assuming --before accepts message UUIDs like --after does; passing a messageId copied from output instead of the seq number.","solutions":["Use the numeric `seq` value with --before; UUIDs are only valid for --after.","Look up the seq of the reference message first, then pass that number.","Trim/normalize the value to digits only."],"exampleFix":"// before\n--before 6f1c2e34-9a0b-4c8d-8e2f-1a2b3c4d5e6f\n// after\n--before 8470","handlingStrategy":"validation","validationCode":"if (before != null && before !== '' && !/^\\d+$/.test(String(before))) throw new Error(`--before must be a seq number, got: ${before}`);","typeGuard":"const isValidBefore = (v) => v === undefined || v === '' || /^\\d+$/.test(String(v));","tryCatchPattern":"try { await readMessages(page, {...kwargs, before}); } catch (e) { if (String(e.message).startsWith('--before must be')) { console.error(`--before accepts only numeric seq; got \"${before}\"`); } else throw e; }","preventionTips":["Remember --before is seq-only (unlike --after, no UUIDs)","Look up the reference message's seq before paginating with --before","Coerce numeric strings and reject anything non-digit in scripts"],"tags":["invalid-argument","validation","cli"],"backgroundTag":"invalid-argument-format","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}