jackwener/OpenCLI · error · ArgumentError
--seq must be a positive integer (got "${kwargs.seq}")
Error message
--seq must be a positive integer (got "${kwargs.seq}") What it means
When `--seq` is provided to `channel-mark`, the CLI converts it with `Number()` and requires a positive integer (used as the read-up-to sequence number in the request body). Non-integer, zero, negative, or non-numeric values throw ArgumentError including the original input.
Source
Thrown at clis/slock/channel-mark.js:44
],
columns: ['channel', 'action', 'result'],
func: async (page, kwargs) => {
const channel = String(kwargs.channel ?? '').trim();
if (!channel) throw new ArgumentError('channel required');
const hasSeq = kwargs.seq !== undefined && kwargs.seq !== null && kwargs.seq !== '';
if (kwargs.unread && hasSeq) {
throw new ArgumentError('--unread and --seq are mutually exclusive');
}
let pathSuffix;
let body;
let action;
if (kwargs.unread) {
pathSuffix = '/unread';
action = 'unread';
} else if (hasSeq) {
const seq = Number(kwargs.seq);
if (!Number.isInteger(seq) || seq <= 0) throw new ArgumentError(`--seq must be a positive integer (got "${kwargs.seq}")`);
pathSuffix = '/read';
body = { seq };
action = `read-to-${seq}`;
} else {
pathSuffix = '/read-all';
action = 'read-all';
}
await page.goto(SLOCK_HOME_URL);
const snippet = buildChannelScopedSnippet({
channelInput: channel,
method: 'POST',
pathSuffix,
body,
serverIdOverride: kwargs.server,
});
const result = await page.evaluate(`(async () => { ${snippet} })()`);
const data = dispatchEvaluateResult(result);View on GitHub (pinned to 49907e53dc)
Solutions
- Pass a positive integer: `slock channel-mark --channel '#ops' --seq 42`
- Coerce/validate in scripts: `--seq "${SEQ%%.*}"` after checking `${SEQ%%.*}" = "$SEQ` for integers
- Omit --seq to use the default read-all behavior
- Confirm the correct value from `channel-list`/message metadata rather than guessing
Example fix
// before $ slock channel-mark --channel '#ops' --seq 12.5 Error: --seq must be a positive integer (got "12.5") // after $ slock channel-mark --channel '#ops' --seq 13
Defensive patterns
Strategy: validation
Validate before calling
const raw = String(input.seq ?? '').trim();
if (raw !== '') {
const n = Number(raw);
if (!Number.isInteger(n) || n <= 0) throw new Error(`--seq must be a positive integer, got: ${raw}`);
} Type guard
const isPositiveInt = (v) => Number.isInteger(v) && v > 0;
Try / catch
try {
await run(['slock', 'channel-mark', '--channel', channel, '--seq', raw]);
} catch (e) {
if (e instanceof ArgumentError && /--seq must be a positive integer/.test(e.message)) {
console.error('Pass a whole number > 0, or omit --seq for read-all.');
} else throw e;
} Prevention
- Pass sequence numbers, not timestamps or message ids
- Validate integer-ness in scripts before passing --seq
- Quote numeric args to avoid shell/whitespace coercion issues
When it happens
Trigger: `--seq 0`, `--seq -5`, `--seq 12.5`, `--seq abc`, or a quoted/whitespace value like `--seq " 42 "` that Number() coerces to NaN.
Common situations: Passing a timestamp or message id instead of a sequence number, shell quoting artifacts, or scripts feeding float values from JSON.
Understand the failure class
Background: Invalid argument type errors: "must be of type string", "expected X, got Y", and ERR_INVALID_ARG_TYPE explained — this error's family across 15 libraries.
Related errors
- archive search sort must be one of ${SORT_OPTIONS.join(', ')
- archive search mediatype must be one of ${MEDIATYPES.join(',
- archive search limit must be a positive integer
- archive search limit must be <= 100
- archive search query must not be empty
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/8e4593e9408de8ae.
Report an issue: GitHub.