{"record":{"id":"5fe88219dad78942","repo":"theonedev/onedev","slug":"405","errorCode":null,"errorMessage":"405","messagePattern":"405","errorType":"http","errorClass":"ClientException","httpStatus":405,"severity":"error","filePath":"server-plugin/server-plugin-pack-nuget/src/main/java/io/onedev/server/plugin/pack/nuget/NugetPackHandler.java","lineNumber":356,"sourceCode":"\t\t\t\tpathSegments = pathSegments.subList(1, pathSegments.size());\n\t\t\t\tif (pathSegments.isEmpty()) {\n\t\t\t\t\tlogger.warn(\"Package version is missing\");\n\t\t\t\t\tthrow new ClientException(SC_BAD_REQUEST);\n\t\t\t\t}\n\t\t\t\tvar version = pathSegments.get(0);\n\n\t\t\t\tLockUtils.run(getLockName(projectId, name), () -> transactionService.run(() -> {\n\t\t\t\t\tvar project = checkProject(projectId, true);\n\t\t\t\t\tvar pack = packService.findByNameAndVersion(project, TYPE, name, version);\n\t\t\t\t\tif (pack != null) {\n\t\t\t\t\t\tpackService.delete(pack);\n\t\t\t\t\t\tresponse.setStatus(SC_NO_CONTENT);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tresponse.setStatus(SC_NOT_FOUND);\n\t\t\t\t\t}\n\t\t\t\t}));\n\t\t\t} else {\n\t\t\t\tthrow new ClientException(SC_METHOD_NOT_ALLOWED);\n\t\t\t}\n\t\t} else if (currentSegment.equals(\"query\")) {\n\t\t\tsessionService.run(() -> {\n\t\t\t\tvar nameQuery = request.getParameter(\"q\");\n\t\t\t\tif (StringUtils.isBlank(nameQuery))\n\t\t\t\t\tnameQuery = null;\n\t\t\t\telse \n\t\t\t\t\tnameQuery = decodeQuery(nameQuery);\n\t\t\t\tvar skip = request.getParameter(\"skip\");\n\t\t\t\tint offset = 0;\n\t\t\t\tif (StringUtils.isNotBlank(skip))\n\t\t\t\t\toffset = Integer.parseInt(skip);\n\t\t\t\tvar count = 0;\n\t\t\t\tvar take = request.getParameter(\"take\");\n\t\t\t\tif (StringUtils.isNotBlank(take))\n\t\t\t\t\tcount = Math.min(Integer.parseInt(take), MAX_QUERY_COUNT);\n\t\t\t\t\n\t\t\t\tboolean includePrerelease = \"true\".equals(request.getParameter(\"prerelease\"));","sourceCodeStart":338,"sourceCodeEnd":374,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-plugin/server-plugin-pack-nuget/src/main/java/io/onedev/server/plugin/pack/nuget/NugetPackHandler.java#L338-L374","documentation":"The NuGet package resource under this segment only supports PUT (publish) and DELETE; any other method (GET/POST/PATCH...) reaches the else branch and throws ClientException(SC_METHOD_NOT_ALLOWED), returned as HTTP 405 with an Allow-style contract of PUT/DELETE.","triggerScenarios":"Sending GET or POST to the package content path instead of the 'query'/'registration'/'package' read endpoints; a client misrouting download requests to the publish/delete resource; health checks hitting the package path with HEAD/GET.","commonSituations":"Confusing the publish endpoint (<feed> root) with download endpoints (package/{id}/{version}/{file}); older tooling versions using different NuGet resource layouts; typo'd base URLs so downloads land on the wrong resource.","solutions":["Use GET on the 'package/{id}/{version}/{file}' route for downloads, not the publish/delete resource","Use PUT to publish and DELETE to remove packages on this resource","Point 'dotnet nuget' / Visual Studio at the service index so clients pick the correct resource URLs","Check proxy rewrites do not collapse distinct NuGet route prefixes into one"],"exampleFix":"// before\nGET /~nuget/project-x/My.Package/1.2.3/My.Package.1.2.3.nupkg   # wrong route -> 405\n// after\nGET /~nuget/project-x/package/My.Package/1.2.3/My.Package.1.2.3.nupkg","handlingStrategy":"validation","validationCode":"// only PUT/DELETE are valid on the package resource\nconst allowed = ['PUT','DELETE'];\nif (!allowed.includes(method)) throw new Error(`use PUT/DELETE for package resource, got ${method}`);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Consult the NuGet v3 service index for correct resource URLs","Keep download traffic on package/... routes","Lint CI scripts for HTTP verbs per endpoint"],"tags":["http","nuget","method-not-allowed","rest"],"backgroundTag":"unsupported-operation","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"}