{"record":{"id":"4867d69bbdf1c7a0","repo":"jackwener/OpenCLI","slug":"nuget-search","errorCode":"nuget search","errorMessage":"No NuGet packages matched \"${query}\".","messagePattern":"No NuGet packages matched \"(.+?)\"\\.","errorType":"exception","errorClass":"EmptyResultError","httpStatus":null,"severity":"warning","filePath":"clis/nuget/search.js","lineNumber":50,"sourceCode":"        'version',\n        'title',\n        'description',\n        'authors',\n        'tags',\n        'totalDownloads',\n        'verified',\n        'projectUrl',\n        'url',\n    ],\n    func: async (args) => {\n        const query = requireString(args.query, 'query');\n        const limit = requireBoundedInt(args.limit, 20, 1000);\n        const prerelease = args.prerelease === true ? 'true' : 'false';\n        const url = `${NUGET_SEARCH_BASE}/query?q=${encodeURIComponent(query)}&take=${limit}&prerelease=${prerelease}`;\n        const body = await nugetFetch(url, 'nuget search');\n        const list = Array.isArray(body?.data) ? body.data : [];\n        if (!list.length) {\n            throw new EmptyResultError('nuget search', `No NuGet packages matched \"${query}\".`);\n        }\n        return list.slice(0, limit).map((pkg, i) => {\n            const id = typeof pkg?.id === 'string' ? pkg.id : '';\n            return {\n                rank: i + 1,\n                id,\n                version: typeof pkg?.version === 'string' ? pkg.version : null,\n                title: typeof pkg?.title === 'string' ? pkg.title : null,\n                description: typeof pkg?.description === 'string' ? pkg.description : null,\n                authors: joinAuthors(pkg?.authors),\n                tags: joinTags(pkg?.tags),\n                totalDownloads: typeof pkg?.totalDownloads === 'number' ? pkg.totalDownloads : null,\n                verified: pkg?.verified === true,\n                projectUrl: typeof pkg?.projectUrl === 'string' ? pkg.projectUrl : null,\n                url: id ? `https://www.nuget.org/packages/${id}` : '',\n            };\n        });\n    },","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/nuget/search.js#L32-L68","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Broaden the query — use fewer, more general keywords.","Pass prerelease:true if the package may only have prerelease versions.","Verify the package exists on nuget.org in a browser; if private, point the tool at the right feed.","Check spelling/casing of the intended package id and retry.","Reduce filters (take/limit are already bounded; ensure no extra constraints were added)."],"exampleFix":"// before\nawait nugetSearch('newtonsoft json net core exact super specific', { prerelease: false }); // EmptyResultError\n// after\nawait nugetSearch('newtonsoft json', { prerelease: true }); // broader query, prereleases allowed","handlingStrategy":"try-catch","validationCode":"if (typeof query !== 'string' || !query.trim()) throw new Error('query required');\n// optionally pre-check via the flat container:\nconst res = await fetch('https://api.nuget.org/v3/index.json'); // ensure service reachable","typeGuard":"null","tryCatchPattern":"try {\n  const results = await nugetSearch(query, { prerelease: true });\n} catch (err) {\n  if (err.name === 'EmptyResultError') {\n    console.warn(`No matches for \"${query}\"; try broader keywords or prerelease:true`);\n  } else throw err;\n}","preventionTips":["Use short, general search terms instead of full package names.","Enable prerelease:true when targeting preview packages.","Confirm public packages exist on nuget.org; use the right feed for private ones.","Handle EmptyResultError as a normal 'no results' case, not a crash."],"tags":["nuget","empty-result","search","no-matches"],"backgroundTag":"empty-result-set","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}