apache/maven · warning
Invalid artifact version {}: {}
Error message
Invalid artifact version {}: {} What it means
Warning from DefaultArtifactResolver.resolve when a resolved SNAPSHOT artifact's version matches Artifact.VERSION_FILE_PATTERN (timestamped snapshot like 1.0-20260821.123456-7): group(3) should be the build number, but Integer.parseInt on it throws NumberFormatException. Maven logs 'Invalid artifact version' and simply skips attaching SnapshotArtifactRepositoryMetadata (build number/timestamp metadata) for that artifact; resolution itself is not rolled back.
Source
Thrown at compat/maven-compat/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java:215
} else {
throw new ArtifactResolutionException(e.getMessage(), artifact, remoteRepositories, e);
}
}
artifact.selectVersion(result.getArtifact().getVersion());
artifact.setFile(result.getArtifact().getFile());
artifact.setResolved(true);
if (artifact.isSnapshot()) {
Matcher matcher = Artifact.VERSION_FILE_PATTERN.matcher(artifact.getVersion());
if (matcher.matches()) {
Snapshot snapshot = new Snapshot();
snapshot.setTimestamp(matcher.group(2));
try {
snapshot.setBuildNumber(Integer.parseInt(matcher.group(3)));
artifact.addMetadata(new SnapshotArtifactRepositoryMetadata(artifact, snapshot));
} catch (NumberFormatException e) {
logger.warn("Invalid artifact version " + artifact.getVersion() + ": " + e.getMessage());
}
}
}
}
}
@Override
public ArtifactResolutionResult resolveTransitively(
Set<Artifact> artifacts,
Artifact originatingArtifact,
ArtifactRepository localRepository,
List<ArtifactRepository> remoteRepositories,
ArtifactMetadataSource source,
ArtifactFilter filter)
throws ArtifactResolutionException, ArtifactNotFoundException {
return resolveTransitively(
artifacts,
originatingArtifact,View on GitHub (pinned to e4093d4e12)
Solutions
- Locate the declaration: mvn dependency:tree -Dverbose and grep for the malformed timestamped version; correct it to a proper -SNAPSHOT or a well-formed timestamped version (-N with numeric N).
- If the bad artifact sits in the local repository, delete that artifact's directory and re-resolve from a clean source.
- Check mirrors/repository rewriting rules (Nexus/Artifactory version policies) that could alter snapshot filenames.
- Regenerate any scripts that construct version strings to enforce the <base>-<timestamp>-<buildNumber> format.
Example fix
<!-- before --> <version>1.2-20260821.101010-abc</version> <!-- after: rely on snapshot metadata --> <version>1.2-SNAPSHOT</version>
Defensive patterns
Strategy: validation
Validate before calling
private static final Pattern TS = Pattern.compile("^(.*)-(\\d{8}\\.\\d{6})-(\\d+)$");
boolean wellFormedSnapshotVersion(String v) { return TS.matcher(v).matches(); } Prevention
- Reference snapshots as <version>X.Y-SNAPSHOT</version>; let Maven expand timestamped forms.
- Delete hand-forged timestamped artifacts from the local repo when seen.
- Audit custom version-rewriting plugins/mirrors for malformed suffixes.
When it happens
Trigger: A snapshot artifact version string whose suffix after the timestamp is non-numeric, e.g. 1.0-20260821.123456-x or 1.0-20260821.123456- (empty), reaches resolve(). This typically means a hand-crafted version in a dependency declaration, a mirror rewriting version strings, or a repository serving malformed snapshot filenames that got installed into the local repo.
Common situations: Manually pinned timestamped snapshot versions in pom.xml with typos; dependency:go-offline or scripts fabricating version strings; custom repository managers that mangle snapshot filenames; migrating from formats like -SNAPSHOT-1 to pure timestamped forms incorrectly.
Related errors
- Error retrieving previous build number for artifact '" + art
- Could not parse current Maven version: {}
- Cannot read metadata from '{}': {}
- {} could not be retrieved from repository: {} due to an erro
- Error installing metadata: {}
AI-assisted analysis of apache/maven@e4093d4e12 (2026-08-21).
Data as JSON: /api/errors/3dadf3565c9c48f2.
Report an issue: GitHub.