{"record":{"id":"5951cdf160b95dd5","repo":"theonedev/onedev","slug":"metadata-not-found","errorCode":null,"errorMessage":"Metadata not found","messagePattern":"Metadata not found","errorType":"http","errorClass":"ClientException","httpStatus":400,"severity":"error","filePath":"server-plugin/server-plugin-pack-gem/src/main/java/io/onedev/server/plugin/pack/gem/GemPackHandler.java","lineNumber":161,"sourceCode":"\n\t\t\t\tbyte[] metadataBytes = null;\n\t\t\t\ttry (var is = new TarArchiveInputStream(new BufferedInputStream(new FileInputStream(tempFile), BUFFER_SIZE))) {\n\t\t\t\t\tTarArchiveEntry entry;\n\t\t\t\t\twhile ((entry = is.getNextTarEntry()) != null) {\n\t\t\t\t\t\tif (entry.getName().equals(\"metadata.gz\")) {\n\t\t\t\t\t\t\tvar baos = new ByteArrayOutputStream();\n\t\t\t\t\t\t\tvar copied = copyWithMaxSize(new GZIPInputStream(is), baos, MAX_METADATA_SIZE);\n\t\t\t\t\t\t\tif (copied == -1)\n\t\t\t\t\t\t\t\tthrow new ClientException(SC_NOT_ACCEPTABLE, \"Metadata exceeds maximum size: \" + MAX_METADATA_SIZE);\n\t\t\t\t\t\t\tmetadataBytes = baos.toByteArray();\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\tthrow new RuntimeException(e);\n\t\t\t\t}\n\t\t\t\tif (metadataBytes == null)\n\t\t\t\t\tthrow new ClientException(SC_BAD_REQUEST, \"Metadata not found\");\n\n\t\t\t\tString name = null;\n\t\t\t\tString version = null;\n\t\t\t\tString platform = null;\n\t\t\t\tvar metadata = (MappingNode) new Yaml().compose(new InputStreamReader(new ByteArrayInputStream(metadataBytes)));\n\t\t\t\tfor (var tuple : metadata.getValue()) {\n\t\t\t\t\tvar keyNode = (ScalarNode) tuple.getKeyNode();\n\t\t\t\t\tif (keyNode.getValue().equals(\"name\")) {\n\t\t\t\t\t\tname = ((ScalarNode) tuple.getValueNode()).getValue();\n\t\t\t\t\t} else if (keyNode.getValue().equals(\"version\")) {\n\t\t\t\t\t\tvar versionNode = (MappingNode) tuple.getValueNode();\n\t\t\t\t\t\tfor (var versionTuple : versionNode.getValue()) {\n\t\t\t\t\t\t\tvar versionKeyNode = (ScalarNode) versionTuple.getKeyNode();\n\t\t\t\t\t\t\tif (versionKeyNode.getValue().equals(\"version\")) {\n\t\t\t\t\t\t\t\tversion = ((ScalarNode) versionTuple.getValueNode()).getValue();\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}","sourceCodeStart":143,"sourceCodeEnd":179,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-plugin/server-plugin-pack-gem/src/main/java/io/onedev/server/plugin/pack/gem/GemPackHandler.java#L143-L179","documentation":"After scanning the uploaded .gem tar archive, the handler expects a metadata.gz entry whose contents describe the package. If no entry named metadata.gz was found before end-of-archive, a 400 ClientException 'Metadata not found' is thrown because the file is not a valid gem package.","triggerScenarios":"Uploading a file with .gem extension that is not a real gem tarball (e.g. renamed jar/zip), or a corrupted/truncated gem archive where metadata.gz is missing.","commonSituations":"CI pipeline publishing the wrong artifact to the gem registry endpoint; file corrupted in transit or by build tooling; manually crafted uploads.","solutions":["Verify the file is a valid gem: run `gem specification file.gem` locally before publishing.","Rebuild the package with `gem build *.gemspec` and re-upload.","Check the CI publish step is uploading the .gem artifact, not another build output."],"exampleFix":"# before\ncurl -u user:token --upload-file target/app.jar .../gems\n# after\ngem build app.gemspec\ncurl -u user:token --upload-file app-1.0.0.gem .../gems","handlingStrategy":"validation","validationCode":"# validate the artifact is a real gem before publishing\ntar -tf mygem.gem | grep -q '^metadata.gz$' || { echo 'not a valid gem'; exit 1; }","typeGuard":null,"tryCatchPattern":"try { upload(file) } catch (e) { if (e.httpStatus === 400 && e.message === 'Metadata not found') { failFast('artifact is not a gem'); } else { throw e; } }","preventionTips":["Run `gem specification` as a CI smoke test before publishing.","Ensure the publish job references the .gem artifact, not other build outputs.","Verify artifact integrity (checksum) after build and before upload."],"tags":["gem","package-upload","invalid-archive"],"backgroundTag":"missing-required-argument","analyzedSha":"d44925c47c37992c828ea673a5f9620539bc3ff2","analyzedAt":"2026-09-06T07:18:27.995Z","contentChangedAt":"2026-09-06T07:18:27.995Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}