{"record":{"id":"f49d3e206c2e6fae","repo":"theonedev/onedev","slug":"can-not-redeploy-package-s-s","errorCode":null,"errorMessage":"Can not redeploy package: %s:%s","messagePattern":"Can not redeploy package: (.+?):(.+?)","errorType":"http","errorClass":"HttpResponseAwareException","httpStatus":409,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/service/impl/DefaultPackService.java","lineNumber":444,"sourceCode":"\t\treturn packs;\n\t}\n\n\t@Transactional\n\t@Override\n\tpublic void deleteByNameAndVersion(Project project, String type, String name, String version) {\n\t\tvar pack = findByNameAndVersion(project, type, name, version);\n\t\tif (pack != null)\n\t\t\tdelete(pack);\n\t}\n\n\t@Transactional\n\t@Override\n\tpublic void createOrUpdate(Pack pack, Collection<PackBlob> packBlobs, boolean postPublishEvent) {\n\t\tif (!pack.isNew() && packBlobs != null && !pack.getSupport().isVersionMutable(pack)) {\n\t\t\tvar sha256Hashes = packBlobs.stream().map(PackBlob::getSha256Hash).collect(Collectors.toSet());\n\t\t\tfor (var blobReference: pack.getBlobReferences()) {\n\t\t\t\tif (!sha256Hashes.contains(blobReference.getPackBlob().getSha256Hash())) {\n\t\t\t\t\tthrow new HttpResponseAwareException(SC_CONFLICT, \"Can not redeploy package: \"\n\t\t\t\t\t\t\t+ pack.getName() + \":\" + pack.getVersion());\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tdao.persist(pack);\n\t\tif (packBlobs != null) {\n\t\t\tpackBlobs = new HashSet<>(packBlobs);\n\t\t\tfor (var packBlob: packBlobs) {\n\t\t\t\tif (pack.getBlobReferences().stream().noneMatch(it -> it.getPackBlob().equals(packBlob))) {\n\t\t\t\t\tvar blobReference = new PackBlobReference();\n\t\t\t\t\tblobReference.setPack(pack);\n\t\t\t\t\tblobReference.setPackBlob(packBlob);\n\t\t\t\t\tblobReferenceManager.create(blobReference);\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (var blobReference: pack.getBlobReferences()) {\n\t\t\t\tif (packBlobs.stream().noneMatch(it -> it.equals(blobReference.getPackBlob())))\n\t\t\t\t\tblobReferenceManager.delete(blobReference);","sourceCodeStart":426,"sourceCodeEnd":462,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/service/impl/DefaultPackService.java#L426-L462","documentation":"DefaultPackService.createOrUpdate throws HttpResponseAwareException with HTTP 409 CONFLICT when re-publishing (redeploying) an existing, immutable package with a different set of blobs. Since the package's format is not version-mutable, existing blob references must all be present in the new upload; any missing hash would silently change package contents, so the library rejects it.","triggerScenarios":"Calling createOrUpdate (typically via a package publish endpoint) for a pack that already exists, whose support.isVersionMutable(pack) is false, and whose new packBlobs set is missing at least one sha256 hash present in the stored pack.getBlobReferences().","commonSituations":"Re-running a partially changed CI publish job producing different artifacts; republishing a Docker/Maven-style immutable version after rebuilding; file changed between runs so its hash differs; accidentally publishing to an existing version instead of a new one.","solutions":["Publish to a new version number instead of reusing the existing version","Reproduce the exact original build artifacts so all original blob hashes are included","Delete the existing package version and republish if overwriting is acceptable","If the format supports mutable versions, use one that does (where isVersionMutable is true)"],"exampleFix":"// before: redeploying same version with changed artifacts\npackService.createOrUpdate(packWithVersion(\"1.0.0\"), newBlobs, true); // 409 if blobs differ\n// after: use a unique version per build\npack.setName(pack.getName());\npack.setVersion(\"1.0.0-\" + buildNumber);\npackService.createOrUpdate(pack, newBlobs, true);","handlingStrategy":"validation","validationCode":"if (!pack.isNew() && packBlobs != null && !pack.getSupport().isVersionMutable(pack)) {\n    var newHashes = packBlobs.stream().map(PackBlob::getSha256Hash).collect(Collectors.toSet());\n    boolean missing = pack.getBlobReferences().stream()\n        .anyMatch(ref -> !newHashes.contains(ref.getPackBlob().getSha256Hash()));\n    if (missing) throw new ExplicitException(\"Re-publishing immutable version requires identical blob set; use a new version.\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    packService.createOrUpdate(pack, packBlobs, true);\n} catch (HttpResponseAwareException e) {\n    if (e.getHttpStatusCode() == 409 && e.getMessage().startsWith(\"Can not redeploy package\")) {\n        // bump version and retry\n    } else throw e;\n}","preventionTips":["Treat published versions as immutable; always publish with fresh unique versions","Make CI builds reproducible so re-publishes produce identical blob hashes","Catch HTTP 409 on publish endpoints in automation and fail fast"],"tags":["package-registry","conflict","http-409","immutability"],"backgroundTag":"version-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"}