jackwener/OpenCLI · warning · EmptyResultError

频道 ${category} 返回空列表。

Error message

频道 ${category} 返回空列表。

What it means

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.

Source

Thrown at clis/toutiao/recommend.js:68

        }
        if (!resp.ok) {
            throw new CommandExecutionError(`toutiao recommend failed: HTTP ${resp.status}`);
        }
        let payload;
        try {
            payload = await resp.json();
        } catch (error) {
            throw new CommandExecutionError(`toutiao recommend returned malformed JSON: ${error?.message || error}`);
        }
        if (payload?.message && payload.message !== 'success') {
            throw new CommandExecutionError(`toutiao recommend returned message=${payload.message}`);
        }
        if (!Array.isArray(payload?.data)) {
            throw new CommandExecutionError('toutiao recommend returned a non-array data field');
        }
        const rows = payload.data.map(mapRecommendRow).filter(Boolean).slice(0, limit);
        if (rows.length === 0) {
            throw new EmptyResultError('toutiao recommend', `频道 ${category} 返回空列表。`);
        }
        // Re-rank (1..N) after filter so ranks are dense even if upstream had ads.
        return rows.map((row, idx) => ({ ...row, rank: idx + 1 }));
    },
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Retry with a different or default category to confirm the issue is channel-specific.
  2. Verify the category slug is valid and currently supported by upstream.
  3. Log the raw payload.data entries; if they exist but all map to null, update mapRecommendRow for the changed schema.
  4. Handle EmptyResultError in calling code as a benign empty state rather than a crash.

Example fix

// before
const items = await recommend({ category: ' blockchain' });
// after
let items;
try { items = await recommend({ category: 'blockchain' }); }
catch (e) {
  if (e instanceof EmptyResultError) items = [];
  else throw e;
}
Defensive patterns

Strategy: try-catch

Try / catch

try {
  const items = await recommend({ category });
} catch (e) {
  if (e instanceof EmptyResultError) {
    console.warn(`No recommendations for this channel; try a default category.`);
    return [];
  }
  throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


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