{"record":{"id":"4975b23a54d9316b","repo":"apache/maven","slug":"cannot-change-the-download-information-for-an-atta","errorCode":null,"errorMessage":"Cannot change the download information for an attached artifact. It is derived from the main artifact.","messagePattern":"Cannot change the download information for an attached artifact\\. It is derived from the main artifact\\.","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"impl/maven-core/src/main/java/org/apache/maven/project/artifact/AttachedArtifact.java","lineNumber":108,"sourceCode":"    @Override\n    public String getBaseVersion() {\n        return parent.getBaseVersion();\n    }\n\n    @Override\n    public void setBaseVersion(String baseVersion) {\n        throw new UnsupportedOperationException(\"Cannot change the version information for an attached artifact.\"\n                + \" It is derived from the main artifact.\");\n    }\n\n    @Override\n    public String getDownloadUrl() {\n        return parent.getDownloadUrl();\n    }\n\n    @Override\n    public void setDownloadUrl(String downloadUrl) {\n        throw new UnsupportedOperationException(\"Cannot change the download information for an attached artifact.\"\n                + \" It is derived from the main artifact.\");\n    }\n\n    @Override\n    public void setGroupId(String groupId) {\n        throw new UnsupportedOperationException(\n                \"Cannot change the groupId for an attached artifact.\" + \" It is derived from the main artifact.\");\n    }\n\n    @Override\n    public ArtifactRepository getRepository() {\n        return parent.getRepository();\n    }\n\n    @Override\n    public void setRepository(ArtifactRepository repository) {\n        throw new UnsupportedOperationException(\"Cannot change the repository information for an attached artifact.\"\n                + \" It is derived from the main artifact.\");","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/impl/maven-core/src/main/java/org/apache/maven/project/artifact/AttachedArtifact.java#L90-L126","documentation":"Download-location metadata is inherited from the main artifact: getDownloadUrl() delegates to the parent and setDownloadUrl throws UnsupportedOperationException on attached artifacts.","triggerScenarios":"Calling setDownloadUrl(...) on an AttachedArtifact, e.g. relocation or deployment code that stamps a download URL on every produced artifact.","commonSituations":"Deploy/relocation tooling iterating over project artifacts including attached ones; code moved from DefaultArtifact where the setter was permitted.","solutions":["Set the download URL on the main artifact instead","Prefer project-level distributionManagement/relocation configuration over per-artifact mutation","Skip attached artifacts when stamping URLs"],"exampleFix":"// before\nattached.setDownloadUrl(url);\n\n// after\nproject.getArtifact().setDownloadUrl(url);","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"static boolean isAttachedArtifact(Artifact a) {\n    return a instanceof org.apache.maven.project.artifact.AttachedArtifact;\n}","tryCatchPattern":"if (isAttachedArtifact(artifact)) {\n    project.getArtifact().setDownloadUrl(url);\n} else {\n    artifact.setDownloadUrl(url);\n}","preventionTips":["Prefer distributionManagement for relocation instead of per-artifact URL mutation","Stamp URLs on the main artifact only"],"tags":["maven","artifact","attached-artifact","immutable","download-url"],"backgroundTag":"immutable-object-mutation","analyzedSha":"e4093d4e120eac99d6bdce5ba67cace2f3085c97","analyzedAt":"2026-08-21T22:58:24.034Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}