theonedev/onedev · error · ClientException
Package version not found in metadata
Error message
Package version not found in metadata
What it means
The gem metadata must include a 'version' entry. If parsing succeeds but no version value was captured, the handler throws 400 'Package version not found in metadata'. Version is required to store and address the package.
Source
Thrown at server-plugin/server-plugin-pack-gem/src/main/java/io/onedev/server/plugin/pack/gem/GemPackHandler.java:187
if (keyNode.getValue().equals("name")) {
name = ((ScalarNode) tuple.getValueNode()).getValue();
} else if (keyNode.getValue().equals("version")) {
var versionNode = (MappingNode) tuple.getValueNode();
for (var versionTuple : versionNode.getValue()) {
var versionKeyNode = (ScalarNode) versionTuple.getKeyNode();
if (versionKeyNode.getValue().equals("version")) {
version = ((ScalarNode) versionTuple.getValueNode()).getValue();
break;
}
}
} else if (keyNode.getValue().equals("platform")) {
platform = ((ScalarNode) tuple.getValueNode()).getValue();
}
}
if (name == null)
throw new ClientException(SC_BAD_REQUEST, "Package name not found in metadata");
if (version == null)
throw new ClientException(SC_BAD_REQUEST, "Package version not found in metadata");
String finalName = name;
String finalVersion = version;
String finalPlatform = platform;
byte[] finalMetadataBytes = metadataBytes;
LockUtils.run(getLockName(projectId, name), () -> transactionService.run(() -> {
var project = projectService.load(projectId);
PackBlob packBlob;
try (var is = new FileInputStream(tempFile)) {
packBlob = packBlobService.load(packBlobService.uploadBlob(projectId, is, null));
} catch (IOException e) {
throw new RuntimeException(e);
}
GemData data;
var pack = packService.findByNameAndVersion(project, TYPE, finalName, finalVersion);
if (pack == null) {
pack = new Pack();View on GitHub (pinned to d44925c47c)
Solutions
- Rebuild the gem with a gemspec that sets s.version (e.g. '1.0.0') and verify with `gem specification`.
- Confirm metadata contents: `tar -xOf mygem.gem metadata.gz | gunzip | grep version`.
- Regenerate metadata with standard tooling rather than editing the archive.
Example fix
# before (gemspec) # gem.version missing # after Gem::Specification.new do |s| s.version = '1.0.0' end
Defensive patterns
Strategy: validation
Validate before calling
# confirm metadata has a version before upload
meta=$(tar -xOf mygem.gem metadata.gz | gunzip)
echo "$meta" | grep -q '^version:' || { echo 'missing version in metadata'; exit 1; } Try / catch
try { upload(gemFile) } catch (e) { if (e.httpStatus === 400 && /version not found/.test(e.message)) { rebuildFromValidGemspec(); } else { throw e; } } Prevention
- Set s.version explicitly in every gemspec.
- Never strip fields when repackaging gems.
- Validate with `gem specification mygem.gem version` in CI.
When it happens
Trigger: Uploading a gem whose metadata YAML lacks the 'version' key — malformed gemspec, hand-built metadata, or a builder that omitted version.
Common situations: Custom packaging scripts dropping the version field; patched gems with stripped metadata; very old or exotic gem formats.
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
- Package name not found in metadata
- Metadata exceeds maximum size: ${MAX_METADATA_SIZE}
- Metadata not found
- Package already exists (name: %s, version: %s)
- Chart name or version not specified
AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06).
Data as JSON: /api/errors/9e1ea131249eb4f4.
Report an issue: GitHub.