{"record":{"id":"91e89ded4ba862ad","repo":"jackwener/OpenCLI","slug":"no-packagist-packages-matched-query","errorCode":null,"errorMessage":"No Packagist packages matched \"${query}\".","messagePattern":"No Packagist packages matched \"(.+?)\"\\.","errorType":"exception","errorClass":"EmptyResultError","httpStatus":null,"severity":"info","filePath":"clis/packagist/search.js","lineNumber":31,"sourceCode":"    name: 'search',\n    access: 'read',\n    description: 'Search Packagist (PHP / Composer) packages by keyword',\n    domain: 'packagist.org',\n    strategy: Strategy.PUBLIC,\n    browser: false,\n    args: [\n        { name: 'query', positional: true, required: true, help: 'Search keyword (e.g. \"symfony\", \"laravel http\")' },\n        { name: 'limit', type: 'int', default: 30, help: 'Max packages (1-100, single Packagist page)' },\n    ],\n    columns: ['rank', 'package', 'description', 'downloads', 'favers', 'repository', 'url'],\n    func: async (args) => {\n        const query = requireString(args.query, 'query');\n        const limit = requireBoundedInt(args.limit, 30, 100);\n        const url = `${PACKAGIST_BASE}/search.json?q=${encodeURIComponent(query)}&per_page=${limit}`;\n        const body = await packagistFetch(url, 'packagist search');\n        const list = Array.isArray(body?.results) ? body.results : [];\n        if (!list.length) {\n            throw new EmptyResultError('packagist search', `No Packagist packages matched \"${query}\".`);\n        }\n        return list.slice(0, limit).map((row, i) => ({\n            rank: i + 1,\n            package: String(row.name ?? '').trim(),\n            description: String(row.description ?? '').trim(),\n            downloads: row.downloads != null ? Number(row.downloads) : null,\n            favers: row.favers != null ? Number(row.favers) : null,\n            repository: String(row.repository ?? '').trim(),\n            url: String(row.url ?? '').trim(),\n        }));\n    },\n});\n","sourceCodeStart":13,"sourceCodeEnd":44,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/packagist/search.js#L13-L44","documentation":"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.","triggerScenarios":"`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).","commonSituations":"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.","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"],"exampleFix":"// before\nawait searchPackagist('my/super-specific-package-name-v2-beta');\n// after\ntry { return await searchPackagist(query); }\ncatch (e) {\n  if (e instanceof EmptyResultError) return [];\n  throw e;\n}","handlingStrategy":"try-catch","validationCode":"const q = query.trim();\nif (!q || q.length < 2) throw new Error('Search query too short or empty');","typeGuard":"function hasSearchResults(b) { return b != null && typeof b === 'object' && Array.isArray(b.results) && b.results.length > 0; }","tryCatchPattern":"try {\n  return await packagistSearch(query, limit);\n} catch (e) {\n  if (/no packages matched/i.test(e.message)) return [];\n  throw e;\n}","preventionTips":["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"],"tags":["empty-result","search","packagist"],"backgroundTag":"empty-search-results","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}