theonedev/onedev · error · ClientException

Package already exists (name: ${name}, version: ${version})

Error message

Package already exists (name: ${name}, version: ${version})

What it means

When publishing a PyPI package, if the pack's data already records the same file name in its sha256BlobHashes map, the package (name+version) is considered already published and a ClientException with HTTP 409 (Conflict) 'Package already exists' is thrown. OneDev does not overwrite an existing package version.

Source

Thrown at server-plugin/server-plugin-pack-pypi/src/main/java/io/onedev/server/plugin/pack/pypi/PypiPackHandler.java:172

										pack.setName(name);
										pack.setVersion(version);
										pack.setProject(project);
										data = new PypiData(attributes, new LinkedHashMap<>());
										pack.setData(data);
									} else {
										data = (PypiData) pack.getData();
									}

									Build build = null;
									if (buildId != null)
										build = buildService.load(buildId);
									pack.setBuild(build);
									pack.setUser(SecurityUtils.getUser());
									pack.setPublishDate(new Date());
									
									if (data.getSha256BlobHashes().containsKey(fileName)) {
										var errorMessage = String.format("Package already exists (name: %s, version: %s)", name, version);
										throw new ClientException(SC_CONFLICT, errorMessage);
									} 
									data.getSha256BlobHashes().put(fileName, sha256Hash);
									
									var packBlobs = data.getSha256BlobHashes().values().stream()
											.map(hash -> packBlobService.findBySha256Hash(projectId, hash))
											.filter(Objects::nonNull)
											.collect(toList());
									packService.createOrUpdate(pack, packBlobs, data.getSha256BlobHashes().size() == 1);									
								}));
								response.setStatus(SC_OK);
								break;
							}
						}
					}
				} catch (IOException | FileUploadException e) {
					throw new RuntimeException(e);
				}
			} else {

View on GitHub (pinned to d44925c47c)

Solutions

  1. Bump the package version and republish.
  2. Delete the existing package version in OneDev (pack management UI) if it should be replaced, then republish.
  3. Make the CI publish step idempotent: skip publishing if the version already exists, or use a unique version like a build-number suffix.

Example fix

// before
version=1.0.0  # already published, rerun fails
// after
version=1.0.1  # or delete existing pack version in OneDev before re-running publish
Defensive patterns

Strategy: try-catch

Validate before calling

# check whether the pack version already exists before publishing
exists = requests.get(f'{base}/api/packs?project={pid}&type=pypi&name={name}&version={version}').ok

Try / catch

if resp.status_code == 409 and 'Package already exists' in resp.text:
    bump_version_and_retry()

Prevention

When it happens

Trigger: Re-running a CI publish step without bumping the version; uploading the same package version a second time; publishing an artifact whose filename already exists in the target pack version.

Common situations: Manual pipeline retries, mutable/latest version tags instead of unique semantic versions, sharing one pack version across different branch builds.

Understand the failure class

Background: "already exists" / EEXIST / FileAlreadyExistsException: what the 'file already exists' error means and how to fix it — this error's family across 37 libraries.

Related errors


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