{"record":{"id":"986ecaaa6d66aa59","repo":"jackwener/OpenCLI","slug":"category","errorCode":null,"errorMessage":"频道 ${category} 返回空列表。","messagePattern":"频道 (.+?) 返回空列表。","errorType":"exception","errorClass":"EmptyResultError","httpStatus":null,"severity":"warning","filePath":"clis/toutiao/recommend.js","lineNumber":68,"sourceCode":"        }\n        if (!resp.ok) {\n            throw new CommandExecutionError(`toutiao recommend failed: HTTP ${resp.status}`);\n        }\n        let payload;\n        try {\n            payload = await resp.json();\n        } catch (error) {\n            throw new CommandExecutionError(`toutiao recommend returned malformed JSON: ${error?.message || error}`);\n        }\n        if (payload?.message && payload.message !== 'success') {\n            throw new CommandExecutionError(`toutiao recommend returned message=${payload.message}`);\n        }\n        if (!Array.isArray(payload?.data)) {\n            throw new CommandExecutionError('toutiao recommend returned a non-array data field');\n        }\n        const rows = payload.data.map(mapRecommendRow).filter(Boolean).slice(0, limit);\n        if (rows.length === 0) {\n            throw new EmptyResultError('toutiao recommend', `频道 ${category} 返回空列表。`);\n        }\n        // Re-rank (1..N) after filter so ranks are dense even if upstream had ads.\n        return rows.map((row, idx) => ({ ...row, rank: idx + 1 }));\n    },\n});\n","sourceCodeStart":50,"sourceCodeEnd":74,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/toutiao/recommend.js#L50-L74","documentation":"This EmptyResultError is thrown by the toutiao recommend command when the upstream returned a valid array but no rows survived mapRecommendRow().filter(Boolean).slice(0, limit). Like the hot-board variant, an empty result after validation is treated as an explicit 'no data' outcome, reported with the requested channel (category) name.","triggerScenarios":"Calling 'toutiao recommend --category <name>' where the channel returns an empty data array, or every row is dropped because mapRecommendRow returns null (missing required fields) or the limit slice yields nothing.","commonSituations":"Requesting a category that currently has no recommendations (niche/invalid category slug); upstream filtering out all items for the requester; schema change making mapRecommendRow return null for all rows.","solutions":["Retry with a different or default category to confirm the issue is channel-specific.","Verify the category slug is valid and currently supported by upstream.","Log the raw payload.data entries; if they exist but all map to null, update mapRecommendRow for the changed schema.","Handle EmptyResultError in calling code as a benign empty state rather than a crash."],"exampleFix":"// before\nconst items = await recommend({ category: ' blockchain' });\n// after\nlet items;\ntry { items = await recommend({ category: 'blockchain' }); }\ncatch (e) {\n  if (e instanceof EmptyResultError) items = [];\n  else throw e;\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const items = await recommend({ category });\n} catch (e) {\n  if (e instanceof EmptyResultError) {\n    console.warn(`No recommendations for this channel; try a default category.`);\n    return [];\n  }\n  throw e;\n}","preventionTips":["Validate category slugs against a known-good list before calling.","Fall back to a default category when one channel is empty.","Treat empty results as data, not failure, in dashboards/aggregators.","Investigate schema drift if every category starts returning empty."],"tags":["empty-result","upstream-api","cli","no-data"],"backgroundTag":"upstream-empty-result","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}