{"record":{"id":"30219f8d89b68d3d","repo":"jackwener/OpenCLI","slug":"xianyu-search-response-did-not-include-an-items-ar","errorCode":null,"errorMessage":"Xianyu search response did not include an items array","messagePattern":"Xianyu search response did not include an items array","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/xianyu/search.js","lineNumber":245,"sourceCode":"        if (result?.error === 'blocked') {\n            throw new CommandExecutionError('Xianyu returned a verification page or blocked the current browser session');\n        }\n        if (result?.error === 'mtop-not-ready') {\n            throw selectorError('window.lib.mtop', '闲鱼页面未完成初始化，无法调用搜索接口');\n        }\n        if (!result || typeof result !== 'object') {\n            throw new CommandExecutionError('Xianyu search returned a malformed response');\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_TOKEN/.test(errorCode) || /FAIL_SYS_SESSION_EXPIRED|SESSION_EXPIRED/.test(errorMessage)) {\n            throw new AuthRequiredError('www.goofish.com', 'Xianyu search requires a logged-in browser session');\n        }\n        if (result?.error) {\n            throw new CommandExecutionError(errorMessage || `Xianyu search request failed: ${result.error}`);\n        }\n        if (!Array.isArray(result.items)) {\n            throw new CommandExecutionError('Xianyu search response did not include an items array');\n        }\n        const items = result.items;\n        if (!items.length) {\n            throw new EmptyResultError('xianyu search', '没有匹配的商品（筛选条件可能过窄，或当前关键词无结果）');\n        }\n        return items.map((item, index) => ({ rank: index + 1, ...item }));\n    },\n});\nexport const __test__ = {\n    ROWS_PER_PAGE,\n    MAX_LIMIT,\n    normalizeLimit,\n    buildSearchUrl,\n    parsePriceArg,\n    buildSearchFilter,\n    buildExtraFilterValue,\n};\n","sourceCodeStart":227,"sourceCodeEnd":263,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/xianyu/search.js#L227-L263","documentation":"After error handling, the CLI requires result.items to be an array. If the successful-shaped response lacks an items array (null or a non-array), a CommandExecutionError is thrown, since the parser cannot map items into ranked results.","triggerScenarios":"The in-page script returns an object without a valid items array — e.g. the response parser found no item list in the mtop payload because the API response shape changed or the parsed data node was missing.","commonSituations":"Goofish updating their mtop response schema (field renames/moves), edge-case responses (all-ads page, special result types) where the extractor fails to collect items.","solutions":["Retry once to rule out a transient malformed payload","Update the library to a version matching the current Goofish response schema","Report the issue with the keyword/filters used if it reproduces consistently"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { await xianyuSearch(args); } catch (e) { if (e instanceof CommandExecutionError && /items array/.test(e.message)) { await wait(3000); return xianyuSearch(args); } throw e; }","preventionTips":["Retry once on this error to rule out transient payload issues","Update the library when goofish.com changes its response schema","Report reproducible cases with the exact keyword and filters used"],"tags":["schema-mismatch","parsing","xianyu"],"backgroundTag":"missing-response-field","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}