jackwener/OpenCLI · warning · EmptyResultError

nuget search

nuget search

Error message

No NuGet packages matched "${query}".

What it means

An EmptyResultError thrown when the NuGet Search API returns a data array with zero items for the given query. The library performs the search and requires at least one match to produce a ranked result list; an empty match set is surfaced as this error.

Source

Thrown at clis/nuget/search.js:50

        'version',
        'title',
        'description',
        'authors',
        'tags',
        'totalDownloads',
        'verified',
        'projectUrl',
        'url',
    ],
    func: async (args) => {
        const query = requireString(args.query, 'query');
        const limit = requireBoundedInt(args.limit, 20, 1000);
        const prerelease = args.prerelease === true ? 'true' : 'false';
        const url = `${NUGET_SEARCH_BASE}/query?q=${encodeURIComponent(query)}&take=${limit}&prerelease=${prerelease}`;
        const body = await nugetFetch(url, 'nuget search');
        const list = Array.isArray(body?.data) ? body.data : [];
        if (!list.length) {
            throw new EmptyResultError('nuget search', `No NuGet packages matched "${query}".`);
        }
        return list.slice(0, limit).map((pkg, i) => {
            const id = typeof pkg?.id === 'string' ? pkg.id : '';
            return {
                rank: i + 1,
                id,
                version: typeof pkg?.version === 'string' ? pkg.version : null,
                title: typeof pkg?.title === 'string' ? pkg.title : null,
                description: typeof pkg?.description === 'string' ? pkg.description : null,
                authors: joinAuthors(pkg?.authors),
                tags: joinTags(pkg?.tags),
                totalDownloads: typeof pkg?.totalDownloads === 'number' ? pkg.totalDownloads : null,
                verified: pkg?.verified === true,
                projectUrl: typeof pkg?.projectUrl === 'string' ? pkg.projectUrl : null,
                url: id ? `https://www.nuget.org/packages/${id}` : '',
            };
        });
    },

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Broaden the query — use fewer, more general keywords.
  2. Pass prerelease:true if the package may only have prerelease versions.
  3. Verify the package exists on nuget.org in a browser; if private, point the tool at the right feed.
  4. Check spelling/casing of the intended package id and retry.
  5. Reduce filters (take/limit are already bounded; ensure no extra constraints were added).

Example fix

// before
await nugetSearch('newtonsoft json net core exact super specific', { prerelease: false }); // EmptyResultError
// after
await nugetSearch('newtonsoft json', { prerelease: true }); // broader query, prereleases allowed
Defensive patterns

Strategy: try-catch

Validate before calling

if (typeof query !== 'string' || !query.trim()) throw new Error('query required');
// optionally pre-check via the flat container:
const res = await fetch('https://api.nuget.org/v3/index.json'); // ensure service reachable

Type guard

null

Try / catch

try {
  const results = await nugetSearch(query, { prerelease: true });
} catch (err) {
  if (err.name === 'EmptyResultError') {
    console.warn(`No matches for "${query}"; try broader keywords or prerelease:true`);
  } else throw err;
}

Prevention

When it happens

Trigger: Calling the nuget search command (query handler) with a query string that matches no packages — nonsense terms, overly specific keywords, a package id that doesn't exist, or take/limit and prerelease=false filtering out all candidates (e.g. only prerelease versions exist).

Common situations: Misspelled package names; searching for private/internal packages on nuget.org instead of the corporate feed; searching exact ids that were deleted; setting prerelease:false while the only versions are prerelease; overly long queries that over-constrain matching.

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/4867d69bbdf1c7a0. Report an issue: GitHub.