theonedev/onedev · error · HttpResponseAwareException

Can not redeploy package: %s:%s

Error message

Can not redeploy package: %s:%s

What it means

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.

Source

Thrown at server-core/src/main/java/io/onedev/server/service/impl/DefaultPackService.java:444

		return packs;
	}

	@Transactional
	@Override
	public void deleteByNameAndVersion(Project project, String type, String name, String version) {
		var pack = findByNameAndVersion(project, type, name, version);
		if (pack != null)
			delete(pack);
	}

	@Transactional
	@Override
	public void createOrUpdate(Pack pack, Collection<PackBlob> packBlobs, boolean postPublishEvent) {
		if (!pack.isNew() && packBlobs != null && !pack.getSupport().isVersionMutable(pack)) {
			var sha256Hashes = packBlobs.stream().map(PackBlob::getSha256Hash).collect(Collectors.toSet());
			for (var blobReference: pack.getBlobReferences()) {
				if (!sha256Hashes.contains(blobReference.getPackBlob().getSha256Hash())) {
					throw new HttpResponseAwareException(SC_CONFLICT, "Can not redeploy package: "
							+ pack.getName() + ":" + pack.getVersion());
				}
			}
		}
		dao.persist(pack);
		if (packBlobs != null) {
			packBlobs = new HashSet<>(packBlobs);
			for (var packBlob: packBlobs) {
				if (pack.getBlobReferences().stream().noneMatch(it -> it.getPackBlob().equals(packBlob))) {
					var blobReference = new PackBlobReference();
					blobReference.setPack(pack);
					blobReference.setPackBlob(packBlob);
					blobReferenceManager.create(blobReference);
				}
			}
			for (var blobReference: pack.getBlobReferences()) {
				if (packBlobs.stream().noneMatch(it -> it.equals(blobReference.getPackBlob())))
					blobReferenceManager.delete(blobReference);

View on GitHub (pinned to d44925c47c)

Solutions

  1. Publish to a new version number instead of reusing the existing version
  2. Reproduce the exact original build artifacts so all original blob hashes are included
  3. Delete the existing package version and republish if overwriting is acceptable
  4. If the format supports mutable versions, use one that does (where isVersionMutable is true)

Example fix

// before: redeploying same version with changed artifacts
packService.createOrUpdate(packWithVersion("1.0.0"), newBlobs, true); // 409 if blobs differ
// after: use a unique version per build
pack.setName(pack.getName());
pack.setVersion("1.0.0-" + buildNumber);
packService.createOrUpdate(pack, newBlobs, true);
Defensive patterns

Strategy: validation

Validate before calling

if (!pack.isNew() && packBlobs != null && !pack.getSupport().isVersionMutable(pack)) {
    var newHashes = packBlobs.stream().map(PackBlob::getSha256Hash).collect(Collectors.toSet());
    boolean missing = pack.getBlobReferences().stream()
        .anyMatch(ref -> !newHashes.contains(ref.getPackBlob().getSha256Hash()));
    if (missing) throw new ExplicitException("Re-publishing immutable version requires identical blob set; use a new version.");
}

Try / catch

try {
    packService.createOrUpdate(pack, packBlobs, true);
} catch (HttpResponseAwareException e) {
    if (e.getHttpStatusCode() == 409 && e.getMessage().startsWith("Can not redeploy package")) {
        // bump version and retry
    } else throw e;
}

Prevention

When it happens

Trigger: 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().

Common situations: 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.

Related errors


AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06). Data as JSON: /api/errors/f49d3e206c2e6fae. Report an issue: GitHub.