{"record":{"id":"fa563c7960ff293a","repo":"theonedev/onedev","slug":"no-agent-package-to-download","errorCode":null,"errorMessage":"No agent package to download","messagePattern":"No agent package to download","errorType":"exception","errorClass":"ExplicitException","httpStatus":null,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/web/resource/AgentResource.java","lineNumber":43,"sourceCode":"import io.onedev.commons.utils.ZipUtils;\nimport io.onedev.server.OneDev;\nimport io.onedev.server.service.AgentService;\nimport io.onedev.server.service.AgentTokenService;\nimport io.onedev.server.service.SettingService;\nimport io.onedev.server.model.AgentToken;\nimport io.onedev.server.security.SecurityUtils;\n\npublic class AgentResource extends AbstractResource {\n\n\tprivate static final long serialVersionUID = 1L;\n\n\t@Override\n\tprotected ResourceResponse newResourceResponse(Attributes attributes) {\n\t\tif (!SecurityUtils.isAdministrator()) \n\t\t\tthrow new UnauthorizedException();\n\t\t\n\t\tif (!new File(Bootstrap.installDir, \"agent\").exists())\n\t\t\tthrow new ExplicitException(\"No agent package to download\");\n\n\t\tResourceResponse response = new ResourceResponse();\n\t\tresponse.setContentType(MimeTypes.OCTET_STREAM);\n\t\tresponse.disableCaching();\n\t\t\n\t\tString fileName = StringUtils.substringAfterLast(\n\t\t\t\tattributes.getRequest().getUrl().getPath(), \"/\");\n\t\tresponse.setFileName(fileName);\n\t\t\n\t\tresponse.setWriteCallback(new WriteCallback() {\n\n\t\t\t@Override\n\t\t\tpublic void writeData(Attributes attributes) throws IOException {\n\t\t\t\tFile tempDir = FileUtils.createTempDir(\"agent\");\n\t\t\t\ttry {\n\t\t\t\t\tString agentVersion = OneDev.getInstance(AgentService.class).getAgentVersion();\n\t\t\t\t\t\n\t\t\t\t\tFile agentDir = new File(tempDir, \"agent\");","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/web/resource/AgentResource.java#L25-L61","documentation":"Identical to the agent-package check in AgentResource: when an administrator requests the agent package but the '<installDir>/agent' directory does not exist on the server, OneDev throws this ExplicitException instead of serving the binary.","triggerScenarios":"GET on the agent download resource by an administrator while new File(Bootstrap.installDir, \"agent\") does not exist.","commonSituations":"Server installed from a minimal archive without the agent bundle; installDir env/launch config pointing to the wrong directory (e.g. after moving the installation); filesystem cleanup removed the agent folder; running dev build from source without packaged agent resources.","solutions":["Ensure the complete OneDev distribution's 'agent' directory exists at the install dir; reinstall/repair if missing.","Correct Bootstrap.installDir / launch configuration so it points to the directory that actually contains the 'agent' folder.","Check disk/cleanup policies that might have deleted the folder and re-extract it from the distribution archive."],"exampleFix":"// before\nexport ONODEV_INSTALL=/opt/onedev-wrong\n\n// after: point to dir containing 'agent'\nexport ONODEV_INSTALL=/opt/onedev","handlingStrategy":"validation","validationCode":"// Verify presence of the agent package before download attempts\nif (!new File(Bootstrap.installDir, \"agent\").exists()) {\n    // restore from distribution archive first\n    throw new IllegalStateException(\"Missing agent package at \" + Bootstrap.installDir);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep the full distribution layout intact under the install dir.","Point installDir env/launch settings at the directory containing 'agent'.","Re-extract the installation archive if the agent folder is deleted."],"tags":["agent","missing-file","installation"],"backgroundTag":"file-not-found","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"}