jackwener/OpenCLI · error · ArgumentError

xianyu reply accepts either item_id/user_id or --rank, not b

Error message

xianyu reply accepts either item_id/user_id or --rank, not both

What it means

The xianyu reply command supports two mutually exclusive targeting modes: explicit item_id/user_id pair, or --rank (position of a conversation in the xianyu inbox). Passing --rank together with item_id and/or user_id is ambiguous and rejected with this ArgumentError during argument normalization at clis/xianyu/reply.js:26-28.

Source

Thrown at clis/xianyu/reply.js:27

    access: 'write',
    description: '回复指定闲鱼私信会话',
    domain: 'www.goofish.com',
    strategy: Strategy.COOKIE,
    navigateBefore: false,
    browser: true,
    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');
            }

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Remove --rank and rely on item_id + user_id, or drop the IDs and use only --rank.
  2. If automating from inbox output, standardize on --rank exclusively and stop forwarding positional IDs.

Example fix

// before (ambiguous)
await xianyuReply({ item_id: '1038951278192', user_id: '3650092411', rank: 2, text: 'hi' });
// after: pick one mode
await xianyuReply({ rank: 2, text: 'hi' });
Defensive patterns

Strategy: validation

Validate before calling

const idsGiven = Boolean(kwargs.item_id || kwargs.user_id);
const rankGiven = Number(kwargs.rank) > 0;
if (idsGiven && rankGiven) throw new Error('Pass either item_id/user_id or --rank, not both.');

Try / catch

try {
  await reply(kwargs);
} catch (e) {
  if (String(e.message).includes('not both')) {
    // prefer explicit IDs when both are present
    const { rank, ...rest } = kwargs;
    return reply(rest);
  }
  throw e;
}

Prevention

When it happens

Trigger: Invoking `xianyu reply <item_id> <user_id> --text ... --rank 2` (or any --rank > 0 with either ID present). Condition: normalizeRank(kwargs.rank) > 0 && (hasItemId || hasUserId).

Common situations: Scripting a reply from a saved inbox rank but accidentally also passing positional IDs copied from a previous invocation; a wrapper template that always injects item_id/user_id while the user adds --rank.

Related errors


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