{"record":{"id":"3ccd96b39b1152c3","repo":"apache/maven","slug":"the-given-artifact-is-not-resolved","errorCode":null,"errorMessage":"The given artifact is not resolved","messagePattern":"The given artifact is not resolved","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"impl/maven-impl/src/main/java/org/apache/maven/impl/AbstractSession.java","lineNumber":263,"sourceCode":"        return allNodes.computeIfAbsent(node, n -> new DefaultNode(this, n, verbose));\n    }\n\n    @Nonnull\n    @Override\n    public Artifact getArtifact(@Nonnull org.eclipse.aether.artifact.Artifact artifact) {\n        return getArtifact(Artifact.class, artifact);\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    @Override\n    public <T extends Artifact> T getArtifact(Class<T> clazz, org.eclipse.aether.artifact.Artifact artifact) {\n        Cache<org.eclipse.aether.artifact.Artifact, Artifact> map = allArtifacts.computeIfAbsent(\n                clazz, c -> Cache.newCache(Cache.ReferenceType.WEAK, \"AbstractSession-Artifacts-\" + c.getSimpleName()));\n        if (clazz == Artifact.class) {\n            return (T) map.computeIfAbsent(artifact, a -> new DefaultArtifact(this, a));\n        } else if (clazz == DownloadedArtifact.class) {\n            if (artifact.getPath() == null) {\n                throw new IllegalArgumentException(\"The given artifact is not resolved\");\n            } else {\n                return (T) map.computeIfAbsent(artifact, a -> new DefaultDownloadedArtifact(this, a));\n            }\n        } else if (clazz == ProducedArtifact.class) {\n            return (T) map.computeIfAbsent(artifact, a -> new DefaultProducedArtifact(this, a));\n        } else {\n            throw new IllegalArgumentException(\"Unsupported Artifact class: \" + clazz);\n        }\n    }\n\n    @Nonnull\n    @Override\n    public Dependency getDependency(@Nonnull org.eclipse.aether.graph.Dependency dependency) {\n        return allDependencies.computeIfAbsent(dependency, d -> new DefaultDependency(this, d));\n    }\n\n    @Override\n    public List<org.eclipse.aether.repository.RemoteRepository> toRepositories(List<RemoteRepository> repositories) {","sourceCodeStart":245,"sourceCodeEnd":281,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/impl/maven-impl/src/main/java/org/apache/maven/impl/AbstractSession.java#L245-L281","documentation":"Thrown by AbstractSession.getArtifact(DownloadedArtifact.class, artifact) when the underlying Eclipse Resolver artifact has a null path, meaning it has never been resolved to a file in the local repository. The Maven API distinguishes plain Artifact (metadata only) from DownloadedArtifact (backed by a resolved file), and only the latter can be created from a resolved artifact. Requesting a DownloadedArtifact from an unresolved artifact is a programming error, not a resolution failure.","triggerScenarios":"Calling session.getArtifact(DownloadedArtifact.class, aetherArtifact) (directly or via a helper) where the org.eclipse.aether.artifact.Artifact was built from coordinates only (e.g. new DefaultArtifact('g:a:v:jar')) and never passed through ArtifactResolver / RepositorySystem.resolveArtifacts, so artifact.getPath() returns null.","commonSituations":"Maven 4 plugin or extension code that mixes the new org.apache.maven.api Session with raw resolver artifacts; resolving an artifact, then re-creating coordinates objects and losing the path; unit tests that construct artifacts by hand instead of resolving them; code that assumes getArtifact always returns a file-backed instance.","solutions":["Resolve the artifact first with session.getService(ArtifactResolver.class).resolve(request) so the resolver sets a path, then call getArtifact(DownloadedArtifact.class, ...)","If you only need coordinates/properties and not the file, request Artifact.class instead of DownloadedArtifact.class","Check aetherArtifact.getPath() != null before asking for a DownloadedArtifact and fail with a clearer message"],"exampleFix":"// before\nDownloadedArtifact da = session.getArtifact(DownloadedArtifact.class, aetherArtifact);\n\n// after\nif (aetherArtifact.getPath() == null) {\n    throw new IllegalStateException('artifact not resolved: ' + aetherArtifact);\n}\nDownloadedArtifact da = session.getArtifact(DownloadedArtifact.class, aetherArtifact);","handlingStrategy":"validation","validationCode":"if (aetherArtifact.getPath() == null) {\n    throw new IllegalStateException(\n            'Artifact ' + aetherArtifact + ' has no path; resolve it before requesting a DownloadedArtifact');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Resolve artifacts through ArtifactResolver before converting to DownloadedArtifact","Request Artifact.class when you only need coordinates, not the file","Never assume a freshly built org.eclipse.aether.artifact.Artifact has a path"],"tags":["maven","artifact-resolution","maven-api","programming-error"],"backgroundTag":"unresolved-artifact","analyzedSha":"e4093d4e120eac99d6bdce5ba67cace2f3085c97","analyzedAt":"2026-08-21T22:58:24.034Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}