jackwener/OpenCLI · info · EmptyResultError
No Maven Central artifacts matched "${query}".
Error message
No Maven Central artifacts matched "${query}". What it means
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.
Source
Thrown at clis/maven/search.js:31
name: 'search',
access: 'read',
description: 'Search Maven Central by keyword (artifact name, groupId, tag)',
domain: 'search.maven.org',
strategy: Strategy.PUBLIC,
browser: false,
args: [
{ name: 'query', positional: true, required: true, help: 'Search keyword (e.g. "jackson", "guava", "ai.koog")' },
{ name: 'limit', type: 'int', default: 30, help: 'Max artifacts (1-200)' },
],
columns: ['rank', 'coordinate', 'groupId', 'artifactId', 'latestVersion', 'packaging', 'versions', 'lastPublished', 'repository', 'url'],
func: async (args) => {
const query = requireString(args.query, 'query');
const limit = requireBoundedInt(args.limit, 30, 200);
const url = `${MAVEN_BASE}?q=${encodeURIComponent(query)}&rows=${limit}&wt=json`;
const body = await mavenFetch(url, 'maven search');
const docs = Array.isArray(body?.response?.docs) ? body.response.docs : [];
if (!docs.length) {
throw new EmptyResultError('maven search', `No Maven Central artifacts matched "${query}".`);
}
return docs.slice(0, limit).map((d, i) => {
const groupId = String(d.g ?? '').trim();
const artifactId = String(d.a ?? '').trim();
const coord = groupId && artifactId ? `${groupId}:${artifactId}` : '';
return {
rank: i + 1,
coordinate: coord,
groupId,
artifactId,
latestVersion: String(d.latestVersion ?? '').trim(),
packaging: String(d.p ?? '').trim(),
versions: d.versionCount != null ? Number(d.versionCount) : null,
lastPublished: epochMsToIso(d.timestamp),
repository: String(d.repositoryId ?? '').trim(),
url: coord ? `https://central.sonatype.com/artifact/${groupId}/${artifactId}` : '',
};
});View on GitHub (pinned to 49907e53dc)
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
Example fix
// before: full coordinate as free-text query, matches nothing
await mavenSearch({ query: 'com.fasterxml.jackson.core:jackson-databind:2.16.1' });
// after: simple artifact token
await mavenSearch({ query: 'jackson-databind' }); Defensive patterns
Strategy: try-catch
Validate before calling
const q = typeof args.query === 'string' ? args.query.trim() : '';
if (!q) throw new Error('query required');
// optionally pre-check common typos against a known-artifacts list Type guard
function isNonEmptyString(v) { return typeof v === 'string' && v.trim().length > 0; } Try / catch
try {
const docs = await mavenSearch({ query, limit });
} catch (err) {
if (err instanceof EmptyResultError) {
console.log('No artifacts matched; try a simpler query');
return [];
}
throw err;
} Prevention
- 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
When it happens
Trigger: 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).
Common situations: 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.
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/ea3763c35411db44.
Report an issue: GitHub.