jackwener/OpenCLI · warning · EmptyResultError
Maven Central returned 404 for ${url}.
Error message
Maven Central returned 404 for ${url}. What it means
mavenFetch() maps an HTTP 404 from search.maven.org to an EmptyResultError, indicating the requested resource (coordinate or query) does not exist on Maven Central. The library treats 'not found' as an empty-result condition rather than a hard failure.
Source
Thrown at clis/maven/utils.js:83
if (version != null && version.length > 200) {
throw new ArgumentError(`maven version "${version}" is too long (max 200 chars).`);
}
return { groupId, artifactId, version: version ?? null };
}
export async function mavenFetch(url, label) {
let resp;
try {
resp = await fetch(url, { headers: { 'user-agent': UA, accept: 'application/json' } });
}
catch (err) {
throw new CommandExecutionError(
`${label} request failed: ${err?.message ?? err}`,
'Check that search.maven.org is reachable from this network.',
);
}
if (resp.status === 404) {
throw new EmptyResultError(label, `Maven Central returned 404 for ${url}.`);
}
if (resp.status === 429) {
throw new CommandExecutionError(
`${label} returned HTTP 429 (rate limited)`,
'Maven Central throttles bursts; wait a few seconds and retry.',
);
}
if (!resp.ok) {
throw new CommandExecutionError(`${label} returned HTTP ${resp.status}`);
}
let body;
try {
body = await resp.json();
}
catch (err) {
throw new CommandExecutionError(`${label} returned malformed JSON: ${err?.message ?? err}`);
}
return body;View on GitHub (pinned to 49907e53dc)
Solutions
- Verify the exact groupId and artifactId on https://central.sonatype.com or search.maven.org UI.
- Correct typos in the coordinate string.
- If expecting a version, confirm it was actually published (check 'v' URL: repo1.maven.org/maven2/g/a/v/).
- Handle EmptyResultError in your code as 'no data' instead of retrying.
Example fix
// before
const r = await searchByCoord('com.foo:does-not-exist');
// after
try {
const r = await searchByCoord('com.google.guava:guava');
} catch (err) {
if (isNotFound(err)) return null; // treat as no result
throw err;
} Defensive patterns
Strategy: try-catch
Validate before calling
null
Type guard
null
Try / catch
try {
const result = await lookup(coord);
} catch (err) {
if (err instanceof EmptyResultError || /404/.test(err.message)) {
return null; // artifact not on Maven Central
}
throw err;
} Prevention
- Verify coordinates on central.sonatype.com before querying.
- Remember Central hosts only released artifacts — snapshots and JitPack-only projects will 404.
- Treat EmptyResultError as 'no data', not a bug.
- Confirm expected versions exist under repo1.maven.org/maven2/<g>/<a>/<v>/.
When it happens
Trigger: Querying a nonexistent groupId:artifactId, a typo'd coordinate, a removed/unpublished artifact, or a version that was never published to Central.
Common situations: Typos in coordinates; looking up artifacts only on JitPack/Google Maven/Nexus but not Central; snapshots that never got released; region-restricted or renamed artifacts.
Related errors
- Chess.com returned 404 for ${url}
- crates.io returned 404 for ${url}.
- Maven Central has no published versions for ${coordLabel}.
- zhihu answer-detail
- bilibili creator-stats ${bvid}
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/2f5595e5cda6b9f1.
Report an issue: GitHub.