jackwener/OpenCLI · error · ArgumentError
xianyu reply requires item_id/user_id or --rank from xianyu
Error message
xianyu reply requires item_id/user_id or --rank from xianyu inbox
What it means
With rank === 0 (no --rank given), reply needs at least one targeting input, but neither item_id nor user_id was provided. Only --text was passed, so the command cannot determine which conversation to open. Thrown at clis/xianyu/reply.js:32-34.
Source
Thrown at clis/xianyu/reply.js:33
args: [
{ name: 'item_id', positional: true, help: '闲鱼商品 item_id' },
{ name: 'user_id', positional: true, help: '聊一聊对方的 user_id / peerUserId' },
{ name: 'text', required: true, help: 'Message text to send' },
{ name: 'rank', type: 'int', default: 0, help: 'Conversation rank from xianyu inbox; clicks the visible row instead of requiring IDs' },
],
columns: ['status', 'peer_name', 'item_title', 'price', 'location', 'message'],
func: async (page, kwargs) => {
const hasItemId = kwargs.item_id != null && kwargs.item_id !== '';
const hasUserId = kwargs.user_id != null && kwargs.user_id !== '';
const rank = normalizeRank(kwargs.rank);
if (rank > 0 && (hasItemId || hasUserId)) {
throw new ArgumentError('xianyu reply accepts either item_id/user_id or --rank, not both');
}
if (rank === 0 && hasItemId !== hasUserId) {
throw new ArgumentError('xianyu reply requires both item_id and user_id, or --rank from xianyu inbox');
}
if (rank === 0 && !hasItemId && !hasUserId) {
throw new ArgumentError('xianyu reply requires item_id/user_id or --rank from xianyu inbox');
}
const hasIds = hasItemId && hasUserId;
const itemId = hasIds ? normalizeNumericId(kwargs.item_id, 'item_id', '1038951278192') : '';
const userId = hasIds ? normalizeNumericId(kwargs.user_id, 'user_id', '3650092411') : '';
const text = requireText(kwargs.text, 'xianyu reply --text');
const url = hasIds ? buildChatUrl(itemId, userId) : '';
if (hasIds) {
await page.goto(url);
} else {
if (!page.getCurrentUrl || !/https:\/\/www\.goofish\.com\/im\b/.test(await page.getCurrentUrl())) {
await page.goto('https://www.goofish.com/im');
}
}
await page.wait(2);
if (rank > 0) {
requireClickResult(await page.evaluate(buildClickInboxConversationEvaluate(rank - 1)), 'reply rank click');
await page.wait(2);
}View on GitHub (pinned to 49907e53dc)
Solutions
- Pass both `item_id user_id` positionals.
- Or run `xianyu inbox` first and pass `--rank N` for the target conversation.
- Ensure wrapper scripts forward ID arguments even when constructing the command dynamically.
Example fix
// before xianyu reply --text "is this available?" // after xianyu reply 1038951278192 3650092411 --text "is this available?"
Defensive patterns
Strategy: validation
Validate before calling
const hasTarget = (kwargs.item_id && kwargs.user_id) || Number(kwargs.rank) > 0;
if (!hasTarget) throw new Error('Provide item_id+user_id or --rank before calling xianyu reply.'); Try / catch
try {
await reply(kwargs);
} catch (e) {
if (String(e.message).includes('requires item_id/user_id or --rank')) {
const inbox = await inbox(); // pick the latest conversation
return reply({ ...kwargs, rank: 1 });
}
throw e;
} Prevention
- Always include targeting args (IDs or --rank) in scripted invocations.
- Don't strip empty-string args in a way that silently removes required positionals.
- Run `xianyu inbox` first when IDs are unknown.
When it happens
Trigger: Invoking `xianyu reply --text "hello"` with no positional IDs and no --rank.
Common situations: Forgetting the positional arguments when piping text from stdin; a script that dropped empty ID variables before building the command line.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- xianyu messages accepts either item_id/user_id or --rank, no
- xianyu messages requires both item_id and user_id, or --rank
- xianyu messages requires item_id/user_id or --rank from xian
- xianyu reply accepts either item_id/user_id or --rank, not b
- xianyu reply requires both item_id and user_id, or --rank fr
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/460df53a9c6a7ddc.
Report an issue: GitHub.