theonedev/onedev · error · ClientException

Package name param is missing

Error message

Package name param is missing

What it means

To download a package file the URL must be /~pypi/files/<name>/<version>/<fileName>. If the package name segment is absent (fewer than 1 remaining path segment after 'files'), the handler throws ClientException(SC_BAD_REQUEST, "Package name param is missing") → HTTP 400.

Source

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

							bindings.put("baseUrl", "/" + project.getPath() + "/~" + HANDLER_ID + "/files/" + UrlUtils.encodePath(name));
							bindings.put("packs", packs);
							try {
								URL tplUrl = Resources.getResource(getClass(), "package-versions.tpl");
								String template = Resources.toString(tplUrl, UTF_8);
								response.setContentType(CONTENT_TYPE_SIMPLE);
								sendResponse(response, evalTemplate(template, bindings));
								response.setStatus(SC_OK);
							} catch (IOException e) {
								throw new RuntimeException(e);
							}
						} else {
							response.setStatus(SC_NOT_FOUND);
						}
					});
				}
			} else if (currentSegment.equals("files")) {
				if (pathSegments.size() < 1)
					throw new ClientException(SC_BAD_REQUEST, "Package name param is missing");
				else if (pathSegments.size() < 2)
					throw new ClientException(SC_BAD_REQUEST, "Package version param is missing");
				else if (pathSegments.size() < 3)
					throw new ClientException(SC_BAD_REQUEST, "Package file name param is missing");
				
				var name = UrlUtils.decodePath(pathSegments.get(0));
				var version = UrlUtils.decodePath(pathSegments.get(1));
				var fileName = UrlUtils.decodePath(pathSegments.get(2));
				
				sessionService.run(() -> {
					var project = checkProject(projectId, false);
					var pack = packService.findByNameAndVersion(project, TYPE, name, version);
					if (pack != null) {
						var data = (PypiData) pack.getData();
						var sha256BlobHash = data.getSha256BlobHashes().get(fileName);
						if (sha256BlobHash != null) {
							PackBlob packBlob;
							if ((packBlob = packBlobService.checkPackBlob(projectId, sha256BlobHash)) != null) {

View on GitHub (pinned to d44925c47c)

Solutions

  1. Use the full three-segment path: /~pypi/files/<name>/<version>/<fileName>
  2. Copy download links directly from the simple index page instead of hand-crafting them
  3. Check any code that assembles file URLs for lost path segments (encoding/splitting bugs)
  4. Ensure the trailing path isn't stripped by a proxy rewrite

Example fix

// before
GET /myproj/~pypi/files/
// after
GET /myproj/~pypi/files/mypkg/1.0.0/mypkg-1.0.0-py3-none-any.whl
Defensive patterns

Strategy: validation

Validate before calling

function validateFilesUrl(name, version, fileName) {
  if (!name) throw new Error('Package name segment required: /~pypi/files/<name>/<version>/<fileName>');
  if (!version) throw new Error('Version segment missing');
  if (!fileName) throw new Error('File name segment missing');
  return `~pypi/files/${encodeURIComponent(name)}/${encodeURIComponent(version)}/${encodeURIComponent(fileName)}`;
}

Try / catch

try {
  const r = await fetch(filesUrl);
} catch (e) {
  if (e.status === 400 && /param is missing/.test(e.message)) {
    console.error('Malformed /files URL; need name, version and fileName segments', e);
  } else throw e;
}

Prevention

When it happens

Trigger: GET /~pypi/files with no further segments — the pathSegments.size() < 1 check at PypiPackHandler.java:241-242 fires.

Common situations: Hand-built download URLs missing the package name; a broken link generated by an old index template; truncated URL in a script or README example.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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