jackwener/OpenCLI · error · ArgumentError
is required
Error message
is required
What it means
The chat-read command requires an `id` positional argument and normalizes it with parseChatId; the ArgumentError with help text 'is required' is thrown when the id is missing or cannot be parsed into a Kimi chat id. As with maybeNavigateConv, the command navigates with ?chat_enter_method=history so Kimi actually loads the messages.
Source
Thrown at clis/kimi/chat.js:166
// -------- detail --------
cli({
site: 'kimi',
name: 'detail',
access: 'read',
description: 'Open a Kimi chat by ID and return its visible messages.',
domain: KIMI_DOMAIN,
strategy: Strategy.COOKIE,
browser: true,
siteSession: 'persistent',
navigateBefore: false,
args: [
{ name: 'id', positional: true, required: true, help: 'Chat ID or full /chat/<id> URL' },
{ name: 'limit', type: 'int', required: false, default: 20 },
],
columns: CHAT_COLUMNS,
func: async (page, kwargs) => {
const id = parseChatId(kwargs.id);
if (!id) throw new ArgumentError('id', 'is required');
// Same trick as maybeNavigateConv: include chat_enter_method=history
// to actually trigger Kimi's messages fetch.
await page.goto(`${KIMI_URL}chat/${id}?chat_enter_method=history`);
for (let i = 0; i < 15; i++) {
const ok = await page.evaluate(`(() => {
const list = document.querySelector('.chat-content-list') || document.querySelector('.message-list');
return !!list && list.querySelectorAll('.chat-content-item, .segment').length > 0;
})()`);
if (ok) break;
await page.wait(1);
}
const turns = await readKimiTurns(page);
if (!turns.length) {
throw new EmptyResultError('kimi detail', `No messages found in /chat/${id}.`);
}
const limit = Number.isInteger(kwargs?.limit) && kwargs.limit > 0 ? kwargs.limit : 20;
return turns.slice(0, limit).map((t, i) => ({ Index: i + 1, Role: t.role, Text: (t.text || '').slice(0, 1200) }));
},View on GitHub (pinned to 49907e53dc)
Solutions
- Pass the id or full https://www.kimi.com/chat/<id> URL as the positional `id` argument
- Copy ChatId exactly from `kimi history` output
- Sanitize the value (trim whitespace, strip trailing punctuation) before passing
- Add shell-level validation that id is non-empty before invoking the command
Example fix
// before
await kimiReadChat({ limit: 20 }); // ArgumentError: id is required
// after
await kimiReadChat({ id: 'abc123', limit: 20 });
// or from a URL:
await kimiReadChat({ id: 'https://www.kimi.com/chat/abc123', limit: 20 }); Defensive patterns
Strategy: validation
Validate before calling
function requireKimiId(id) {
const parsed = typeof id === 'string' ? (id.match(/kimi\.com\/chat\/([A-Za-z0-9_-]+)/)?.[1] || (id.match(/^[A-Za-z0-9_-]+$/) ? id : null)) : null;
if (!parsed) throw new Error('kimi chat `id` is required: pass a chat id or kimi.com/chat/<id> URL');
return parsed;
}
const id = requireKimiId(kwargs.id); Type guard
function hasValidChatId(kwargs) {
return typeof kwargs?.id === 'string' && kwargs.id.trim().length > 0 &&
(/^[A-Za-z0-9_-]+$/.test(kwargs.id.trim()) || kwargs.id.includes('kimi.com/chat/'));
} Try / catch
try {
await kimiReadChat({ id, limit: 20 });
} catch (e) {
if (e instanceof ArgumentError && /is required/.test(e.message)) {
console.error('Usage: kimi read-chat <id|url> [--limit N]');
process.exitCode = 2;
} else throw e;
} Prevention
- Validate the positional argument exists before invoking the command
- Reuse `kimi history` ChatId values as the source of ids
- Normalize URLs to bare ids in a shared helper before all chat commands
When it happens
Trigger: Calling the command without the positional `id`, with an empty string, or with a value parseChatId cannot resolve (non-Kimi URL, malformed id, extra text around the id).
Common situations: Omitting the positional argument on the CLI; wrapping the id in quotes that include stray characters; pasting a share link in a different URL format; a script building kwargs dynamically and leaving id undefined.
Related errors
- <train-no> must not be empty
- keyword must not be empty
- <from> station must not be empty
- <to> station must not be empty
- who 不能为空
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/f81a7a6dcf861284.
Report an issue: GitHub.