{"record":{"id":"460df53a9c6a7ddc","repo":"jackwener/OpenCLI","slug":"xianyu-reply-requires-item-id-user-id-or-rank-fr","errorCode":null,"errorMessage":"xianyu reply requires item_id/user_id or --rank from xianyu inbox","messagePattern":"xianyu reply requires item_id/user_id or --rank from xianyu inbox","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/xianyu/reply.js","lineNumber":33,"sourceCode":"    args: [\n        { name: 'item_id', positional: true, help: '闲鱼商品 item_id' },\n        { name: 'user_id', positional: true, help: '聊一聊对方的 user_id / peerUserId' },\n        { name: 'text', required: true, help: 'Message text to send' },\n        { name: 'rank', type: 'int', default: 0, help: 'Conversation rank from xianyu inbox; clicks the visible row instead of requiring IDs' },\n    ],\n    columns: ['status', 'peer_name', 'item_title', 'price', 'location', 'message'],\n    func: async (page, kwargs) => {\n        const hasItemId = kwargs.item_id != null && kwargs.item_id !== '';\n        const hasUserId = kwargs.user_id != null && kwargs.user_id !== '';\n        const rank = normalizeRank(kwargs.rank);\n        if (rank > 0 && (hasItemId || hasUserId)) {\n            throw new ArgumentError('xianyu reply accepts either item_id/user_id or --rank, not both');\n        }\n        if (rank === 0 && hasItemId !== hasUserId) {\n            throw new ArgumentError('xianyu reply requires both item_id and user_id, or --rank from xianyu inbox');\n        }\n        if (rank === 0 && !hasItemId && !hasUserId) {\n            throw new ArgumentError('xianyu reply requires item_id/user_id or --rank from xianyu inbox');\n        }\n        const hasIds = hasItemId && hasUserId;\n        const itemId = hasIds ? normalizeNumericId(kwargs.item_id, 'item_id', '1038951278192') : '';\n        const userId = hasIds ? normalizeNumericId(kwargs.user_id, 'user_id', '3650092411') : '';\n        const text = requireText(kwargs.text, 'xianyu reply --text');\n        const url = hasIds ? buildChatUrl(itemId, userId) : '';\n        if (hasIds) {\n            await page.goto(url);\n        } else {\n            if (!page.getCurrentUrl || !/https:\\/\\/www\\.goofish\\.com\\/im\\b/.test(await page.getCurrentUrl())) {\n                await page.goto('https://www.goofish.com/im');\n            }\n        }\n        await page.wait(2);\n        if (rank > 0) {\n            requireClickResult(await page.evaluate(buildClickInboxConversationEvaluate(rank - 1)), 'reply rank click');\n            await page.wait(2);\n        }","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/xianyu/reply.js#L15-L51","documentation":"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.","triggerScenarios":"Invoking `xianyu reply --text \"hello\"` with no positional IDs and no --rank.","commonSituations":"Forgetting the positional arguments when piping text from stdin; a script that dropped empty ID variables before building the command line.","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."],"exampleFix":"// before\nxianyu reply --text \"is this available?\"\n// after\nxianyu reply 1038951278192 3650092411 --text \"is this available?\"","handlingStrategy":"validation","validationCode":"const hasTarget = (kwargs.item_id && kwargs.user_id) || Number(kwargs.rank) > 0;\nif (!hasTarget) throw new Error('Provide item_id+user_id or --rank before calling xianyu reply.');","typeGuard":null,"tryCatchPattern":"try {\n  await reply(kwargs);\n} catch (e) {\n  if (String(e.message).includes('requires item_id/user_id or --rank')) {\n    const inbox = await inbox(); // pick the latest conversation\n    return reply({ ...kwargs, rank: 1 });\n  }\n  throw e;\n}","preventionTips":["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."],"tags":["argument-validation","cli-usage","xianyu"],"backgroundTag":"missing-required-argument","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}