{"record":{"id":"ea3763c35411db44","repo":"jackwener/OpenCLI","slug":"no-maven-central-artifacts-matched-query","errorCode":null,"errorMessage":"No Maven Central artifacts matched \"${query}\".","messagePattern":"No Maven Central artifacts matched \"(.+?)\"\\.","errorType":"exception","errorClass":"EmptyResultError","httpStatus":null,"severity":"info","filePath":"clis/maven/search.js","lineNumber":31,"sourceCode":"    name: 'search',\n    access: 'read',\n    description: 'Search Maven Central by keyword (artifact name, groupId, tag)',\n    domain: 'search.maven.org',\n    strategy: Strategy.PUBLIC,\n    browser: false,\n    args: [\n        { name: 'query', positional: true, required: true, help: 'Search keyword (e.g. \"jackson\", \"guava\", \"ai.koog\")' },\n        { name: 'limit', type: 'int', default: 30, help: 'Max artifacts (1-200)' },\n    ],\n    columns: ['rank', 'coordinate', 'groupId', 'artifactId', 'latestVersion', 'packaging', 'versions', 'lastPublished', 'repository', 'url'],\n    func: async (args) => {\n        const query = requireString(args.query, 'query');\n        const limit = requireBoundedInt(args.limit, 30, 200);\n        const url = `${MAVEN_BASE}?q=${encodeURIComponent(query)}&rows=${limit}&wt=json`;\n        const body = await mavenFetch(url, 'maven search');\n        const docs = Array.isArray(body?.response?.docs) ? body.response.docs : [];\n        if (!docs.length) {\n            throw new EmptyResultError('maven search', `No Maven Central artifacts matched \"${query}\".`);\n        }\n        return docs.slice(0, limit).map((d, i) => {\n            const groupId = String(d.g ?? '').trim();\n            const artifactId = String(d.a ?? '').trim();\n            const coord = groupId && artifactId ? `${groupId}:${artifactId}` : '';\n            return {\n                rank: i + 1,\n                coordinate: coord,\n                groupId,\n                artifactId,\n                latestVersion: String(d.latestVersion ?? '').trim(),\n                packaging: String(d.p ?? '').trim(),\n                versions: d.versionCount != null ? Number(d.versionCount) : null,\n                lastPublished: epochMsToIso(d.timestamp),\n                repository: String(d.repositoryId ?? '').trim(),\n                url: coord ? `https://central.sonatype.com/artifact/${groupId}/${artifactId}` : '',\n            };\n        });","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/maven/search.js#L13-L49","documentation":"This error is thrown by the `maven search` command when the Maven Central search API returns successfully but yields zero result documents. The library treats an empty search result as an EmptyResultError so callers can distinguish 'no matches' from genuine failures like network or parse errors. It means the query was valid but nothing in Maven Central matched it.","triggerScenarios":"Calling the search operation with a `query` string (e.g. a groupId, artifactId fragment, or free-text term) that matches no artifacts in Maven Central, such as a misspelled artifact name, a very obscure or removed artifact, or an over-specific multi-term query. The response body has body.response.docs as an empty array (or missing).","commonSituations":"Typo in the artifact name (e.g. 'jacksion-databind' instead of 'jackson-databind'); searching for an artifact hosted only on JBoss/GitHub Packages/other repos, not Maven Central; using search terms that are too narrow; a library that was deleted or renamed upstream; packaging a groupId+artifactId literal into the free-text query in a way the Lucene index doesn't match.","solutions":["Check the query for typos and simplify it — search a single well-known token (e.g. 'jackson-databind') instead of a full coordinate","Search the exact artifact on https://central.sonatype.com to confirm it exists on Maven Central at all","If searching a specific coordinate, use the coordinate-based operations (requireCoord with groupId:artifactId) instead of free-text search","Broaden the query: drop version numbers, qualifiers like '-sources', or extra words that shrink the result set to zero","Handle EmptyResultError in your caller as a 'no results' UX case rather than a hard failure"],"exampleFix":"// before: full coordinate as free-text query, matches nothing\nawait mavenSearch({ query: 'com.fasterxml.jackson.core:jackson-databind:2.16.1' });\n// after: simple artifact token\nawait mavenSearch({ query: 'jackson-databind' });","handlingStrategy":"try-catch","validationCode":"const q = typeof args.query === 'string' ? args.query.trim() : '';\nif (!q) throw new Error('query required');\n// optionally pre-check common typos against a known-artifacts list","typeGuard":"function isNonEmptyString(v) { return typeof v === 'string' && v.trim().length > 0; }","tryCatchPattern":"try {\n  const docs = await mavenSearch({ query, limit });\n} catch (err) {\n  if (err instanceof EmptyResultError) {\n    console.log('No artifacts matched; try a simpler query');\n    return [];\n  }\n  throw err;\n}","preventionTips":["Start with a short, single-token query and refine from there","Verify the artifact exists on central.sonatype.com before searching programmatically","Treat EmptyResultError as an expected, handled outcome in search UX","Strip version/qualifier suffixes from queries before searching"],"tags":["empty-result","maven","search","input-validation"],"backgroundTag":"empty-search-results","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}