{"record":{"id":"50d168ddd5afdd2f","repo":"apache/maven","slug":"unable-to-get-dependency-information-e-getmes","errorCode":null,"errorMessage":"Unable to get dependency information: \" + e.getMessage()","messagePattern":"Unable to get dependency information: \" \\+ e\\.getMessage\\(\\)","errorType":"exception","errorClass":"ArtifactResolutionException","httpStatus":null,"severity":"error","filePath":"compat/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/DefaultLegacyArtifactCollector.java","lineNumber":305,"sourceCode":"                                // MNG-2123: if the previous node was not a range, then it wouldn't have any available\n                                // versions. We just clobbered the selected version above. (why? I have no idea.)\n                                // So since we are here and this is ranges we must go figure out the version (for a\n                                // third time...)\n                                if (resetArtifact.getVersion() == null && resetArtifact.getVersionRange() != null) {\n\n                                    // go find the version. This is a total hack. See previous comment.\n                                    List<ArtifactVersion> versions = resetArtifact.getAvailableVersions();\n                                    if (versions == null) {\n                                        try {\n                                            MetadataResolutionRequest metadataRequest =\n                                                    new DefaultMetadataResolutionRequest(request);\n\n                                            metadataRequest.setArtifact(resetArtifact);\n                                            versions = source.retrieveAvailableVersions(metadataRequest);\n                                            resetArtifact.setAvailableVersions(versions);\n                                        } catch (ArtifactMetadataRetrievalException e) {\n                                            resetArtifact.setDependencyTrail(node.getDependencyTrail());\n                                            throw new ArtifactResolutionException(\n                                                    \"Unable to get dependency information: \" + e.getMessage(),\n                                                    resetArtifact,\n                                                    request.getRemoteRepositories(),\n                                                    e);\n                                        }\n                                    }\n                                    // end hack\n\n                                    // MNG-2861: match version can return null\n                                    ArtifactVersion selectedVersion = resetArtifact\n                                            .getVersionRange()\n                                            .matchVersion(resetArtifact.getAvailableVersions());\n\n                                    if (selectedVersion != null) {\n                                        resetArtifact.selectVersion(selectedVersion.toString());\n                                    } else {\n                                        throw new OverConstrainedVersionException(\n                                                \"Unable to find a version in \" + resetArtifact.getAvailableVersions()","sourceCodeStart":287,"sourceCodeEnd":323,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/compat/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/DefaultLegacyArtifactCollector.java#L287-L323","documentation":"DefaultLegacyArtifactCollector (the Maven 2/3-legacy transitive dependency resolver) must enumerate available versions when a dependency is declared with a version range. It calls ArtifactMetadataSource.retrieveAvailableVersions(...) to fetch maven-metadata.xml from the configured remote repositories; if that retrieval throws ArtifactMetadataRetrievalException (network failure, missing metadata, authentication error), it is wrapped into ArtifactResolutionException prefixed with 'Unable to get dependency information', carrying the reset artifact, the remote repositories and the original cause.","triggerScenarios":"Resolving a dependency whose version is a range (e.g. [1.0,2.0)) in a build that uses the legacy resolver, while retrieveAvailableVersions fails: repository unreachable, 401/403 due to missing credentials, 404 for the metadata file, proxy interference, or mvn -o (offline) with the metadata not yet cached locally.","commonSituations":"CI builds run with -o/--offline or from within a restricted network; private repository credentials not configured in settings.xml; internal mirror that does not proxy the repository hosting the ranged dependency; ranged dependencies on artifacts whose maven-metadata.xml was never published.","solutions":["Check the wrapped cause (getCause()) to see the real retrieval failure — unauthorized, not found, or connection refused — and fix settings.xml credentials/mirror configuration accordingly","If running with -o or --legacy-local-repository, drop the flag or pre-warm the local cache with one online build","Refresh stale metadata with mvn -U to force re-fetch of maven-metadata.xml","Replace the version range with a concrete pinned version so no metadata enumeration is required"],"exampleFix":"<!-- before -->\n<dependency>\n  <groupId>com.example</groupId>\n  <artifactId>lib</artifactId>\n  <version>[1.0,2.0)</version>\n</dependency>\n\n<!-- after: pin an exact version to avoid remote metadata enumeration -->\n<dependency>\n  <groupId>com.example</groupId>\n  <artifactId>lib</artifactId>\n  <version>1.4.2</version>\n</dependency>","handlingStrategy":"try-catch","validationCode":"// Before resolving a ranged dependency, verify its metadata is reachable\ntry {\n    List<ArtifactVersion> versions = metadataSource.retrieveAvailableVersions(\n            new DefaultMetadataResolutionRequest(request).setArtifact(artifact));\n    if (versions == null || versions.isEmpty()) {\n        throw new IllegalStateException(\"No available versions for \" + artifact.getId()\n                + \" — check repositories/offline mode before resolution\");\n    }\n} catch (ArtifactMetadataRetrievalException e) {\n    throw new IllegalStateException(\"Repository metadata unreachable for \" + artifact.getId(), e);\n}","typeGuard":null,"tryCatchPattern":"try {\n    artifactResolver.resolve(artifactRangeRequest);\n} catch (ArtifactResolutionException e) {\n    if (e.getMessage() != null && e.getMessage().startsWith(\"Unable to get dependency information\")) {\n        Throwable root = e.getCause(); // ArtifactMetadataRetrievalException with the real reason\n        handleMetadataAccess(artifact, root); // e.g. prompt credentials, disable offline, skip module\n    } else {\n        throw e;\n    }\n}","preventionTips":["Prefer pinned dependency versions over ranges in CI builds to avoid remote metadata lookups","Warm the local repository with one full online build before enabling -o offline mode","Configure credentials and mirrors in settings.xml once per environment and assert them in a pre-build check"],"tags":["maven","dependency-resolution","version-range","metadata","remote-repository","legacy-compat"],"backgroundTag":"metadata-retrieval-failed","analyzedSha":"e4093d4e120eac99d6bdce5ba67cace2f3085c97","analyzedAt":"2026-08-21T22:58:24.034Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}