{"record":{"id":"95b22c5e43b23d91","repo":"apache/maven","slug":"unable-to-determine-the-latest-version","errorCode":null,"errorMessage":"Unable to determine the latest version","messagePattern":"Unable to determine the latest version","errorType":"exception","errorClass":"ArtifactNotFoundException","httpStatus":null,"severity":"error","filePath":"compat/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/transform/LatestArtifactTransformation.java","lineNumber":47,"sourceCode":"import org.apache.maven.artifact.resolver.ArtifactNotFoundException;\nimport org.apache.maven.artifact.resolver.ArtifactResolutionException;\n\n/**\n * Describes a version transformation during artifact resolution - \"latest\" type\n */\n@Named(\"latest\")\n@Singleton\n@Deprecated\npublic class LatestArtifactTransformation extends AbstractVersionTransformation {\n\n    @Override\n    public void transformForResolve(Artifact artifact, RepositoryRequest request)\n            throws ArtifactResolutionException, ArtifactNotFoundException {\n        if (Artifact.LATEST_VERSION.equals(artifact.getVersion())) {\n            try {\n                String version = resolveVersion(artifact, request);\n                if (Artifact.LATEST_VERSION.equals(version)) {\n                    throw new ArtifactNotFoundException(\"Unable to determine the latest version\", artifact);\n                }\n\n                artifact.setBaseVersion(version);\n                artifact.updateVersion(version, request.getLocalRepository());\n            } catch (RepositoryMetadataResolutionException e) {\n                throw new ArtifactResolutionException(e.getMessage(), artifact, e);\n            }\n        }\n    }\n\n    @Override\n    public void transformForInstall(Artifact artifact, ArtifactRepository localRepository) {\n        // metadata is added via addPluginArtifactMetadata\n    }\n\n    @Override\n    public void transformForDeployment(\n            Artifact artifact, ArtifactRepository remoteRepository, ArtifactRepository localRepository) {","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/compat/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/transform/LatestArtifactTransformation.java#L29-L65","documentation":"LatestArtifactTransformation.transformForResolve handles artifacts whose literal version is 'LATEST'. It resolves the version from repository metadata; if resolveVersion still returns 'LATEST', no usable versioning metadata exists, and ArtifactNotFoundException('Unable to determine the latest version') is thrown for that artifact. A separate RepositoryMetadataResolutionException (metadata could not be read at all) is converted to ArtifactResolutionException instead.","triggerScenarios":"A dependency or plugin declared with <version>LATEST</version> where maven-metadata.xml for the artifact is absent from all reachable repositories or contains no usable versioning information (resolveVersion falls back to the LATEST marker).","commonSituations":"Using LATEST against a project that was never deployed so no metadata exists; internal mirror not serving metadata; offline builds without cached metadata; LATEST inherited from stale documentation or templates — also generally discouraged because it makes builds non-reproducible.","solutions":["Replace <version>LATEST</version> with a concrete version (or a bounded range) — the recommended, reproducible practice","If LATEST must resolve, ensure the artifact has been deployed at least once so maven-metadata.xml exists in the target repository","Refresh metadata with mvn -U and verify the repository is reachable and listed in the effective POM","Check for typos in groupId/artifactId that would make metadata lookup target a non-existent artifact"],"exampleFix":"<!-- before -->\n<dependency>\n  <groupId>com.example</groupId>\n  <artifactId>lib</artifactId>\n  <version>LATEST</version>\n</dependency>\n\n<!-- after -->\n<dependency>\n  <groupId>com.example</groupId>\n  <artifactId>lib</artifactId>\n  <version>1.4.2</version>\n</dependency>","handlingStrategy":"validation","validationCode":"import org.apache.maven.artifact.Artifact;\n\nboolean usesMetaversion(Artifact a) {\n    String v = a.getVersion();\n    return Artifact.LATEST_VERSION.equals(v) || Artifact.RELEASE_VERSION.equals(v);\n}\n\nif (usesMetaversion(artifact)) {\n    throw new IllegalArgumentException(\n        \"LATEST/RELEASE metaversions make builds non-reproducible; pin a concrete version for \"\n            + artifact.getId());\n}","typeGuard":null,"tryCatchPattern":"try {\n    transformer.transformForResolve(artifact, request);\n} catch (ArtifactNotFoundException e) {\n    if (\"Unable to determine the latest version\".equals(e.getMessage())) {\n        // metadata absent: replace LATEST with a concrete version in the dependency declaration\n        advisePinning(artifact);\n    } else {\n        throw e;\n    }\n}","preventionTips":["Ban LATEST/RELEASE via a CI enforcer rule or code review checklist","Use versions-maven-plugin (display-dependency-updates, use-latest-versions) to manage upgrades explicitly instead of metaversions","If a metaversion is unavoidable in a scratch build, ensure the artifact has been deployed online at least once so metadata exists"],"tags":["maven","version-resolution","latest","metadata","legacy-compat"],"backgroundTag":"unresolved-version-metadata","analyzedSha":"e4093d4e120eac99d6bdce5ba67cace2f3085c97","analyzedAt":"2026-08-21T22:58:24.034Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}