theonedev/onedev · error · ClientException
400
Error message
400
What it means
A generic HTTP 400 ClientException thrown by the NuGet publish (PUT) handler when the uploaded request fails validation checks — notably when the package version parsed from the .nupkg is not SemVer v2 compatible (logged as 'Package version is not a SemVer v2 compatible version'), or when an expected part of the push request (e.g. the package payload) is absent so the else branch rejects with a bare 400.
Source
Thrown at server-plugin/server-plugin-pack-nuget/src/main/java/io/onedev/server/plugin/pack/nuget/NugetPackHandler.java:327
var data = (NugetData) pack.getData();
var nupkgBlob = packBlobService.findBySha256Hash(projectId, data.getNupkgBlobSha256Hash());
if (nupkgBlob != null)
packBlobs.add(nupkgBlob);
pack.setData(new NugetData(data.getNupkgBlobSha256Hash(), snupkgBlob.getSha256Hash(),
data.getMetadata()));
packService.createOrUpdate(pack, packBlobs, false);
response.setStatus(SC_CREATED);
}
}));
} catch (ParseException e) {
logger.warn("Package version is not a SemVer v2 compatible version");
throw new ClientException(SC_BAD_REQUEST);
} finally {
FileUtils.deleteFile(tempFile);
}
} else {
throw new ClientException(SC_BAD_REQUEST);
}
} catch (FileUploadException | IOException e) {
throw new RuntimeException(e);
}
} else if (isDelete) {
if (pathSegments.isEmpty()) {
logger.warn("Package id is missing");
throw new ClientException(SC_BAD_REQUEST);
}
var name = pathSegments.get(0);
pathSegments = pathSegments.subList(1, pathSegments.size());
if (pathSegments.isEmpty()) {
logger.warn("Package version is missing");
throw new ClientException(SC_BAD_REQUEST);
}
var version = pathSegments.get(0);
LockUtils.run(getLockName(projectId, name), () -> transactionService.run(() -> {View on GitHub (pinned to d44925c47c)
Solutions
- Repackage the .nupkg with a SemVer v2 compatible version (no leading zeros, valid prerelease format) and push again.
- Verify you are pushing to the correct OneDev NuGet endpoint (…/nuget/<project>/index.json based source) so the package payload reaches the handler.
- Check the client/proxy is not dropping or truncating the uploaded package body.
- Use a current NuGet client (dotnet nuget push or nuget push) that sends the standard resource-based push request.
Example fix
// before (invalid version) <version>1.02.0</version> // after <version>1.2.0</version> dotnet pack -p:PackageVersion=1.2.0 && dotnet nuget push *.nupkg -s <onedev-nuget-source>
Defensive patterns
Strategy: validation
Validate before calling
# Validate version is SemVer v2 before pushing VERSION=$(xmllint --xpath '//*[local-name()="version"]/text()' *.nuspec 2>/dev/null) if ! echo "$VERSION" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$'; then echo "Version $VERSION is not SemVer v2"; exit 1; fi
Prevention
- Use semver-valid versions (no leading zeros, valid prerelease tags).
- Push via standard dotnet nuget push / nuget push against the OneDev source.
- Confirm the package body is not stripped by proxies.
When it happens
Trigger: PUT push of a .nupkg whose version string is not SemVer v2 compatible; push request missing the required package body/part so the final else throws new ClientException(SC_BAD_REQUEST) with no message.
Common situations: Publishing packages with legacy/nonstandard version strings (leading zeros, invalid prerelease labels) from scripts or older NuGet clients; dotnet nuget push against a wrong endpoint that omits the package part; proxy stripping the multipart/zip body.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06).
Data as JSON: /api/errors/1734a12450bfa885.
Report an issue: GitHub.