jackwener/OpenCLI · info · EmptyResultError

No Semantic Scholar recommendations for "${args.id}".

Error message

No Semantic Scholar recommendations for "${args.id}".

What it means

This EmptyResultError (clis/semanticscholar/recommendations.js:42) is thrown when the recommendations endpoint succeeded but recommendedPapers was an empty array — the service simply has no recommendations for the given paper. It is an expected, benign outcome, not a request failure.

Source

Thrown at clis/semanticscholar/recommendations.js:42

    strategy: Strategy.PUBLIC,
    browser: false,
    args: [
        { name: 'id', positional: true, required: true, help: 'paperId (40-char hex), DOI, arXiv id, or prefixed id' },
        { name: 'limit', type: 'int', default: 10, help: 'Max recommendations (1-500)' },
    ],
    columns: ['rank', 'paperId', 'doi', 'title', 'year', 'firstAuthor', 'citationCount', 'url'],
    func: async (args) => {
        const ref = requirePaperRef(args.id);
        const limit = requireBoundedInt(args.limit, 10, 500);
        const url = `${S2_REC_BASE}/papers/forpaper/${encodeURIComponent(ref)}?fields=${FIELDS}&limit=${limit}`;
        const body = await s2Fetch(url, 'semanticscholar recommendations');

        const recommended = Array.isArray(body?.recommendedPapers) ? body.recommendedPapers : null;
        if (recommended === null) {
            throw new CommandExecutionError('semanticscholar recommendations returned an unexpected payload shape');
        }
        if (!recommended.length) {
            throw new EmptyResultError('semanticscholar recommendations', `No Semantic Scholar recommendations for "${args.id}".`);
        }

        return recommended.slice(0, limit).map((p, i) => normalizePaperRow(p, 'recommendations', { rank: i + 1 }));
    },
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Confirm the paper exists and has citations via `semanticscholar paper <id>` — well-cited papers usually get recommendations.
  2. Try a related, better-established paper as the recommendation seed.
  3. Treat this error as 'no data' in scripts rather than retrying — retrying will not change the outcome.
  4. Wait and retry only if the paper was published very recently; the recommender indexes with a delay.

Example fix

// before
const recs = await recommendations(id); // throws on empty
// after
let recs;
try {
  recs = await recommendations(id);
} catch (err) {
  if (isEmptyResult(err)) recs = []; // no recommendations yet
  else throw err;
}
Defensive patterns

Strategy: fallback

Validate before calling

// Prefer seeds with citation graph presence:
const paper = await cli('semanticscholar paper', id, { json: true });
if ((paper.citationCount ?? 0) === 0) return []; // recommendations will be empty; skip the call

Type guard

function isEmptyResultError(err) {
  return err instanceof Error && err.name === 'EmptyResultError';
}

Try / catch

try {
  recs = await recommendations(id);
} catch (err) {
  if (isEmptyResultError(err)) {
    return { recommendations: [], reason: 'no S2 recommendations for this paper' };
  }
  throw err;
}

Prevention

When it happens

Trigger: Calling `semanticscholar recommendations <id>` for a paper too new, too obscure, or of a type the recommender does not cover; very recent papers with no embedding/citation graph yet; non-English or niche venues with sparse graph data.

Common situations: Querying brand-new preprints days after publication; papers with minimal metadata in the S2 corpus; expecting recommendations for dataset/withdrawn papers; users confusing zero recommendations with an API failure.

Understand the failure class

Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.

Related errors


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