{"record":{"id":"851ba871d2154e2c","repo":"jackwener/OpenCLI","slug":"error-851ba8","errorCode":null,"errorMessage":"闲鱼商品详情接口未返回有效数据","messagePattern":"闲鱼商品详情接口未返回有效数据","errorType":"error_code","errorClass":"EmptyResultError","httpStatus":null,"severity":"error","filePath":"clis/xianyu/item.js","lineNumber":134,"sourceCode":"        { name: 'item_id', required: true, positional: true, help: '闲鱼商品 item_id' },\n    ],\n    columns: ['item_id', 'title', 'price', 'condition', 'brand', 'location', 'seller_name', 'want_count'],\n    func: async (page, kwargs) => {\n        const itemId = normalizeNumericId(kwargs.item_id, 'item_id', '1040754408976');\n        await page.goto(buildItemUrl(itemId));\n        await page.wait(2);\n        const result = await page.evaluate(buildFetchItemEvaluate(itemId));\n        if (result?.error === 'auth-required') {\n            throw new AuthRequiredError('www.goofish.com', 'Xianyu item detail requires a logged-in browser session');\n        }\n        if (result?.error === 'blocked') {\n            throw new EmptyResultError('xianyu item', 'Xianyu item detail is blocked by verification or risk control');\n        }\n        if (result?.error === 'mtop-not-ready') {\n            throw selectorError('window.lib.mtop', '闲鱼页面未完成初始化，无法调用商品详情接口');\n        }\n        if (!result || typeof result !== 'object') {\n            throw new EmptyResultError('xianyu item', '闲鱼商品详情接口未返回有效数据');\n        }\n        const errorCode = String(result.error_code || '');\n        const errorMessage = String(result.error_message || '');\n        if (/FAIL_SYS_SESSION_EXPIRED|SESSION_EXPIRED|FAIL_SYS/.test(errorCode) || /FAIL_SYS_SESSION_EXPIRED|SESSION_EXPIRED/.test(errorMessage)) {\n            throw new AuthRequiredError('www.goofish.com', 'Xianyu item detail requires a logged-in browser session');\n        }\n        if (result.error) {\n            throw new EmptyResultError('xianyu item', errorMessage || `Xianyu item detail request failed: ${result.error}`);\n        }\n        if (!String(result.title || '').trim()) {\n            throw new EmptyResultError('xianyu item', 'No item detail was returned for the specified item_id');\n        }\n        return [result];\n    },\n});\nexport const __test__ = {\n    normalizeNumericId,\n    buildItemUrl,","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/xianyu/item.js#L116-L152","documentation":"After the mtop item-detail call, if the result is null/undefined or not an object, the library throws EmptyResultError('xianyu item', '闲鱼商品详情接口未返回有效数据'). This means page.evaluate did not return a usable payload at all — the in-page fetch either never completed properly or returned nothing structured. It precedes the error_code checks, so it indicates a missing/invalid response shape rather than an API error payload.","triggerScenarios":"Running `xianyu item --item-id <id>` when `page.evaluate(buildFetchItemEvaluate(itemId))` resolves to null, undefined, a primitive, or otherwise a non-object — no `{ error, error_code, title, ... }` payload came back.","commonSituations":"Page didn't finish initializing before evaluate ran (the 2s wait was insufficient); mtop lib (window.lib.mtop) loaded but returned nothing; page navigated or was replaced mid-evaluation; network hiccup swallowed the response.","solutions":["Retry the command — transient page-load timing is the usual cause.","Increase the settle wait so the mtop library finishes initializing before evaluate runs.","If it reproduces, check whether goofish.com changed its page/bootstrap structure and update the evaluate script.","Catch code 'EMPTY_RESULT' and distinguish this hint from genuine 'no data' cases before alerting."],"exampleFix":"// before\nawait page.goto(buildItemUrl(itemId));\nawait page.wait(2);\nconst result = await page.evaluate(buildFetchItemEvaluate(itemId)); // returns undefined if lib not ready\n// after\nawait page.goto(buildItemUrl(itemId));\nawait page.waitForSelector('body');\nawait page.waitForFunction('typeof window.lib !== \"undefined\" && window.lib.mtop'); // ensure mtop ready\nconst result = await page.evaluate(buildFetchItemEvaluate(itemId));","handlingStrategy":"retry","validationCode":"// Ensure page readiness before evaluate (in adapter code):\nawait page.waitForFunction('typeof window.lib !== \"undefined\" && window.lib.mtop');","typeGuard":"function isValidItemPayload(result) {\n  return result !== null && typeof result === 'object' &&\n    ('title' in result || 'error' in result || 'error_code' in result);\n}","tryCatchPattern":"let attempt = 0;\nwhile (attempt < 3) {\n  try {\n    return await cli.run(['xianyu', 'item', '--item-id', itemId]);\n  } catch (err) {\n    const transient = err.code === 'EMPTY_RESULT' &&\n      typeof err.hint === 'string' && err.hint.includes('未返回有效数据');\n    if (!transient || ++attempt >= 3) throw err;\n    await sleep(2000 * attempt);\n  }\n}","preventionTips":["Wait for mtop initialization (window.lib.mtop) before evaluating page scripts.","Retry once or twice on this specific hint — it is usually a timing issue.","Keep the CLI adapter updated if goofish.com changes its bootstrap flow.","Distinguish this 'no valid payload' hint from genuine empty-result hints before alerting."],"tags":["xianyu","mtop","invalid-response","empty-result"],"backgroundTag":"mtop-empty-response","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}