{"record":{"id":"e78e6bd1a37a97e0","repo":"theonedev/onedev","slug":"406","errorCode":null,"errorMessage":"406","messagePattern":"406","errorType":"http","errorClass":"ClientException","httpStatus":406,"severity":"error","filePath":"server-plugin/server-plugin-pack-nuget/src/main/java/io/onedev/server/plugin/pack/nuget/NugetPackHandler.java","lineNumber":619,"sourceCode":"\tprivate String getPackageDownloadUrl(String baseUrl, String name, String version) {\n\t\tname = encodePath(name);\n\t\tversion = encodePath(version);\n\t\treturn baseUrl + \"/package/\" + name + \"/\" + version + \"/\" + name + \".\" + version + \".nupkg\";\n\t}\n\t\n\tprivate void sendResponse(HttpServletResponse response, Object value) {\n\t\ttry {\n\t\t\tresponse.getOutputStream().write(writeJson(value));\n\t\t} catch (IOException e) {\n\t\t\tthrow new RuntimeException(e);\n\t\t}\n\t}\n\n\tprivate Project checkProject(Long projectId, boolean needsToWrite) {\n\t\tvar project = projectService.load(projectId);\n\t\tif (!project.isPackManagement()) {\n\t\t\tlogger.warn(\"Package management not enabled for project '\" + project.getPath() + \"'\");\n\t\t\tthrow new ClientException(SC_NOT_ACCEPTABLE);\n\t\t} else if (needsToWrite && !SecurityUtils.canWritePack(project)) {\n\t\t\tthrow new UnauthorizedException(\"No package write permission for project: \" + project.getPath());\n\t\t} else if (!needsToWrite && !SecurityUtils.canReadPack(project)) {\n\t\t\tthrow new UnauthorizedException(\"No package read permission for project: \" + project.getPath());\n\t\t}\n\t\treturn project;\n\t}\n\n\t@Override\n\tpublic String getApiKey(HttpServletRequest request) {\n\t\treturn request.getHeader(HEADER_API_KEY);\n\t}\n\t\n\t@Override\n\tpublic List<String> normalize(List<String> pathSegments) {\n\t\treturn pathSegments;\n\t}\n","sourceCodeStart":601,"sourceCodeEnd":637,"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#L601-L637","documentation":"checkProject() throws a ClientException with HTTP status 406 (Not Acceptable) when the target project does not have package management (pack management) enabled. The NuGet pack endpoint refuses to serve packages for projects where the feature is turned off.","triggerScenarios":"Calling any NuGet pack endpoint (publish, search, download) against a projectId whose project has 'Pack management' disabled in its settings.","commonSituations":"Pointing a nuget source/publish URL at the wrong project, creating a new project and forgetting to enable pack management before running a CI publish step, or a project template that does not include the feature.","solutions":["Enable package management for the project in the OneDev project settings, then retry.","Verify you are using the correct project ID / URL for the project that has pack management enabled.","If the package belongs to a different project, update your nuget.config / CI publish URL to point at that project's pack endpoint."],"exampleFix":"// before: project without pack management\nPOST /~nuget/pack/<projectIdWithoutFeature>/...\n// after: enable Pack Management on the project in OneDev UI, or use the right projectId","handlingStrategy":"validation","validationCode":"# before publishing, confirm pack management is enabled via OneDev REST:\n# GET /api/projects/{id} and check pack management enabled flag","typeGuard":null,"tryCatchPattern":"resp = requests.post(url, ...)\nif resp.status_code == 406:\n    raise RuntimeError('Enable pack management on project first')","preventionTips":["Enable pack management when creating the project, before wiring CI publish.","Add a CI preflight check that verifies the pack endpoint responds before push.","Double-check the project ID embedded in the nuget source URL."],"tags":["nuget","http-406","project-config","pack-management"],"backgroundTag":"feature-not-enabled","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"}