jackwener/OpenCLI · info · EmptyResultError
No Packagist packages matched "${query}".
Error message
No Packagist packages matched "${query}". What it means
Packagist's search endpoint returned successfully but with zero entries in `results`, so no packages matched the query. Thrown as EmptyResultError to signal 'no results' distinctly from a failure.
Source
Thrown at clis/packagist/search.js:31
name: 'search',
access: 'read',
description: 'Search Packagist (PHP / Composer) packages by keyword',
domain: 'packagist.org',
strategy: Strategy.PUBLIC,
browser: false,
args: [
{ name: 'query', positional: true, required: true, help: 'Search keyword (e.g. "symfony", "laravel http")' },
{ name: 'limit', type: 'int', default: 30, help: 'Max packages (1-100, single Packagist page)' },
],
columns: ['rank', 'package', 'description', 'downloads', 'favers', 'repository', 'url'],
func: async (args) => {
const query = requireString(args.query, 'query');
const limit = requireBoundedInt(args.limit, 30, 100);
const url = `${PACKAGIST_BASE}/search.json?q=${encodeURIComponent(query)}&per_page=${limit}`;
const body = await packagistFetch(url, 'packagist search');
const list = Array.isArray(body?.results) ? body.results : [];
if (!list.length) {
throw new EmptyResultError('packagist search', `No Packagist packages matched "${query}".`);
}
return list.slice(0, limit).map((row, i) => ({
rank: i + 1,
package: String(row.name ?? '').trim(),
description: String(row.description ?? '').trim(),
downloads: row.downloads != null ? Number(row.downloads) : null,
favers: row.favers != null ? Number(row.favers) : null,
repository: String(row.repository ?? '').trim(),
url: String(row.url ?? '').trim(),
}));
},
});
View on GitHub (pinned to 49907e53dc)
Solutions
- Simplify the search query to a shorter keyword and retry
- Check spelling of the package/vendor name
- Verify the package exists at https://packagist.org/search?q=<query> in a browser
- Catch EmptyResultError and present a friendly 'no packages found' message instead of crashing
Example fix
// before
await searchPackagist('my/super-specific-package-name-v2-beta');
// after
try { return await searchPackagist(query); }
catch (e) {
if (e instanceof EmptyResultError) return [];
throw e;
} Defensive patterns
Strategy: try-catch
Validate before calling
const q = query.trim();
if (!q || q.length < 2) throw new Error('Search query too short or empty'); Type guard
function hasSearchResults(b) { return b != null && typeof b === 'object' && Array.isArray(b.results) && b.results.length > 0; } Try / catch
try {
return await packagistSearch(query, limit);
} catch (e) {
if (/no packages matched/i.test(e.message)) return [];
throw e;
} Prevention
- Use short keyword queries; Packagist search is keyword-based, not fuzzy
- Double-check spelling of package/vendor names
- Catch EmptyResultError and render a 'no results' UI state
- Verify existence on packagist.org before automating lookups
When it happens
Trigger: `packagist search` built `${PACKAGIST_BASE}/search.json?q=<query>&per_page=<limit>` and the response's `results` array was empty or absent — the query simply matched no packages (or Packagist returned an unexpected body with no results key).
Common situations: Searching for a package name that doesn't exist on Packagist; overly specific multi-word queries; typos in the vendor/package name; searching a private/unpublished package that isn't indexed.
Related errors
- No 12306 stations match "${keyword}"
- ${label}
- No papers found for author "${authorText}". Try alternate sp
- No papers found. Try a different keyword.
- crates search
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/91e89ded4ba862ad.
Report an issue: GitHub.