{"record":{"id":"4748b8118b92237c","repo":"theonedev/onedev","slug":"can-not-redeploy-package-pack-getname-pack","errorCode":null,"errorMessage":"Can not redeploy package: ${pack.getName()}:${pack.getVersion()}","messagePattern":"Can not redeploy package: (.+?):(.+?)","errorType":"http","errorClass":"HttpResponseAwareException","httpStatus":409,"severity":"error","filePath":"server-plugin/server-plugin-pack-maven/src/main/java/io/onedev/server/plugin/pack/maven/MavenPackHandler.java","lineNumber":408,"sourceCode":"\t\t\t\t\t\tpack.setName(getName(groupId, artifactId));\n\t\t\t\t\t\tpack.setVersion(version != null? version: NONE);\n\t\t\t\t\t\tpack.setPrerelease(version != null && version.endsWith(VERSION_SUFFIX_SNAPSHOT));\n\t\t\t\t\t\tpack.setData(new MavenData());\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tBuild build = null;\n\t\t\t\t\tif (buildId != null)\n\t\t\t\t\t\tbuild = buildService.load(buildId);\n\t\t\t\t\tpack.setBuild(build);\n\t\t\t\t\tpack.setUser(SecurityUtils.getUser());\n\t\t\t\t\tpack.setPublishDate(new Date());\n\t\t\t\t\tMavenData data = (MavenData) pack.getData();\n\t\t\t\t\tvar prevSha256BlobHash = data.getSha256BlobHashes().get(blobName);\n\t\t\t\t\tif (version != null\n\t\t\t\t\t\t\t&& !version.endsWith(VERSION_SUFFIX_SNAPSHOT)\n\t\t\t\t\t\t\t&& prevSha256BlobHash != null\n\t\t\t\t\t\t\t&& !prevSha256BlobHash.equals(sha256BlobHash)) {\n\t\t\t\t\t\tthrow new HttpResponseAwareException(SC_CONFLICT, \"Can not redeploy package: \"\n\t\t\t\t\t\t\t\t+ pack.getName() + \":\" + pack.getVersion());\n\t\t\t\t\t}\n\t\t\t\t\tdata.getSha256BlobHashes().put(blobName, sha256BlobHash);\n\t\t\t\t\tpackService.createOrUpdate(pack, null, false);\n\t\t\t\t\tif (prevSha256BlobHash != null) {\n\t\t\t\t\t\tfor (var blobReference: pack.getBlobReferences()) {\n\t\t\t\t\t\t\tif (blobReference.getPackBlob().getSha256Hash().equals(prevSha256BlobHash)) {\n\t\t\t\t\t\t\t\tpackBlobReferenceService.delete(blobReference);\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tresponse.setStatus(SC_CREATED);\n\t\t\t\t}));\n\t\t\t}\n\t\t} catch (IOException e) {\n\t\t\tthrow new RuntimeException(e);\n\t\t}","sourceCodeStart":390,"sourceCodeEnd":426,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-plugin/server-plugin-pack-maven/src/main/java/io/onedev/server/plugin/pack/maven/MavenPackHandler.java#L390-L426","documentation":"uploadBlob enforces Maven's non-snapshot immutability: if the version does not end in '-SNAPSHOT' and a blob with the same name already exists in the pack with a different SHA-256 hash, redeploying is rejected with HTTP 409 CONFLICT. Released artifacts are meant to be immutable; overwriting with different content is blocked.","triggerScenarios":"Running mvn deploy (or a REST PUT) for a release version like 1.0.0 whose artifact file already exists in the pack but was built with different bytes (new build of the same version).","commonSituations":"Re-running a release build without bumping the version; CI redeploys of release artifacts from rebuilt binaries; accidentally deploying a release version twice from different commits; Gradle/Maven client configured without proper versioning.","solutions":["Bump the project version (e.g. 1.0.0 → 1.0.1) and redeploy — this is the intended fix.","If this is genuinely moving-target content, use a -SNAPSHOT version, which is allowed to change.","Delete the existing pack/version in OneDev (Project > Packages) if it is truly wrong, then redeploy once.","Fix CI so release jobs only deploy from tagged, reproducible builds."],"exampleFix":"// before (pom.xml)\n<version>1.0.0</version>  <!-- 1.0.0 already deployed with different content -->\n// after\n<version>1.0.1</version>","handlingStrategy":"validation","validationCode":"# Refuse to deploy a release version that already exists remotely\nGROUP_PATH=com/acme/app\nVER=1.0.0\nART=app-$VER.jar\nSTATUS=$(curl -s -o /dev/null -w '%{http_code}' -u \"$USER:$TOKEN\" \"$BASE/~maven/1/$GROUP_PATH/$VER/$ART\")\nif [ \"$VER\" != *-SNAPSHOT ] && [ \"$STATUS\" = \"200\" ]; then\n  echo \"Version $VER already deployed — bump the version\"; exit 1\nfi","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Automate version bumps (mvn release:prepare, versions:set) instead of manual edits.","Use -SNAPSHOT during development; reserve release versions for tagged builds.","In CI, deploy only from tag builds with reproducible artifacts."],"tags":["maven","immutable-artifact","conflict","redeploy"],"backgroundTag":"file-already-exists","analyzedSha":"d44925c47c37992c828ea673a5f9620539bc3ff2","analyzedAt":"2026-09-06T07:18:27.995Z","contentChangedAt":"2026-09-06T07:18:27.995Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}