{"record":{"id":"7b3fad2229aa87d6","repo":"theonedev/onedev","slug":"package-version-not-specified","errorCode":null,"errorMessage":"Package version not specified","messagePattern":"Package version not specified","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":151,"sourceCode":"\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) {\n\t\t\t\tpack = new Pack();\n\t\t\t\tpack.setType(TYPE);\n\t\t\t\tpack.setName(name);\n\t\t\t\tpack.setVersion(version);\n\t\t\t\tpack.setPrerelease(version.contains(\"-\"));\n\t\t\t\tpack.setProject(project);\n\t\t\t}\n\t\t\tpack.setData(new CargoData(upload.metadata, packBlob.getSha256Hash()));\n\t\t\tBuild build = null;\n\t\t\tif (buildId != null)","sourceCodeStart":133,"sourceCodeEnd":169,"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#L133-L169","documentation":"Client-input guard in CargoPackHandler.publish: the uploaded metadata JSON lacks a 'vers' field, so the package version is unknown and the package cannot be registered; ClientException 400 is returned. Fix: include a valid version in the cargo metadata.","triggerScenarios":"Thrown at server-plugin/server-plugin-pack-cargo/src/main/java/io/onedev/server/plugin/pack/cargo/CargoPackHandler.java:151 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the metadata includes a non-empty 'vers' value.","Set the version properly in Cargo.toml before publishing."],"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-14T00:17:10.932Z"}