{"record":{"id":"a6ba289b8f60a8ec","repo":"theonedev/onedev","slug":"invalid-package-metadata","errorCode":null,"errorMessage":"Invalid package metadata","messagePattern":"Invalid package metadata","errorType":"http","errorClass":"ClientException","httpStatus":400,"severity":"error","filePath":"server-plugin/server-plugin-pack-cargo/src/main/java/io/onedev/server/plugin/pack/cargo/CargoPackHandler.java","lineNumber":141,"sourceCode":"\t\t\tif (!isPut)\n\t\t\t\tthrow new ClientException(SC_METHOD_NOT_ALLOWED);\n\t\t\tsetYanked(response, projectId, decodePath(pathSegments.get(3)), decodePath(pathSegments.get(4)), false);\n\t\t} else if (isGet) {\n\t\t\tserveIndex(response, projectId, pathSegments);\n\t\t} else {\n\t\t\tthrow new ClientException(SC_METHOD_NOT_ALLOWED);\n\t\t}\n\t}\n\n\tprivate void publish(HttpServletRequest request, HttpServletResponse response, Long projectId, Long buildId) {\n\t\tvar upload = readPublishBody(request);\n\t\tObjectNode metadata;\n\t\ttry {\n\t\t\tvar metadataNode = objectMapper.readTree(upload.metadata);\n\t\t\tif (metadataNode instanceof ObjectNode)\n\t\t\t\tmetadata = (ObjectNode) metadataNode;\n\t\t\telse\n\t\t\t\tthrow new ClientException(SC_BAD_REQUEST, \"Invalid package metadata\");\n\t\t} catch (IOException e) {\n\t\t\tthrow new ClientException(SC_BAD_REQUEST, \"Invalid package metadata\");\n\t\t}\n\n\t\tvar name = metadata.path(\"name\").asText(null);\n\t\tvar version = metadata.path(\"vers\").asText(null);\n\t\tif (StringUtils.isBlank(name))\n\t\t\tthrow new ClientException(SC_BAD_REQUEST, \"Package name not specified\");\n\t\tif (StringUtils.isBlank(version))\n\t\t\tthrow new ClientException(SC_BAD_REQUEST, \"Package version not specified\");\n\t\tif (!name.equals(name.toLowerCase()))\n\t\t\tthrow new ClientException(SC_BAD_REQUEST, \"Package name should be lower case\");\n\t\tLockUtils.run(getLockName(projectId, name), () -> transactionService.run(() -> {\n\t\t\tvar project = checkProject(projectId, true);\n\t\t\tvar packBlobId = packBlobService.uploadBlob(projectId, upload.crateFile, null);\n\t\t\tvar packBlob = packBlobService.load(packBlobId);\n\t\t\tvar pack = packService.findByNameAndVersion(project, TYPE, name, version);\n\t\t\tif (pack == null) {","sourceCodeStart":123,"sourceCodeEnd":159,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-plugin/server-plugin-pack-cargo/src/main/java/io/onedev/server/plugin/pack/cargo/CargoPackHandler.java#L123-L159","documentation":"CargoPackHandler.publish parses the uploaded package metadata JSON; if it is unparseable (IOException) or not a JSON object, the publish is rejected with HTTP 400 'Invalid package metadata'. Indicates a malformed cargo publish payload.","triggerScenarios":"Thrown at server-plugin/server-plugin-pack-cargo/src/main/java/io/onedev/server/plugin/pack/cargo/CargoPackHandler.java:141 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check that the cargo client uploads a valid JSON metadata object.","Verify the publish body structure matches what the handler expects (metadata plus tarball)."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"d44925c47c37992c828ea673a5f9620539bc3ff2","analyzedAt":"2026-09-06T07:18:27.995Z","contentChangedAt":"2026-09-06T07:18:27.995Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}