{"record":{"id":"c8a095a65c9e869f","repo":"theonedev/onedev","slug":"unable-to-find-build-project-s-build-number-c8a095","errorCode":null,"errorMessage":"Unable to find build (project: %s, build number: %d)","messagePattern":"Unable to find build \\(project: (.+?), build number: (.+?)\\)","errorType":"exception","errorClass":"EntityNotFoundException","httpStatus":404,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/web/resource/BuildLogResource.java","lineNumber":62,"sourceCode":"\tprivate static final String PARAM_BUILD = \"build\";\n\t\n\t@Override\n\tprotected ResourceResponse newResourceResponse(Attributes attributes) {\n\t\tPageParameters params = attributes.getParameters();\n\n\t\tLong projectId = params.get(PARAM_PROJECT).toLong();\n\t\tLong buildNumber = params.get(PARAM_BUILD).toOptionalLong();\n\t\tif (buildNumber == null)\n\t\t\tthrow new IllegalArgumentException(\"build number has to be specified\");\n\n\t\tif (!SecurityUtils.isSystem()) {\n\t\t\tProject project = getProjectService().load(projectId);\t\t\t\n\t\t\tBuild build = getBuildService().find(project, buildNumber);\n\n\t\t\tif (build == null) {\n\t\t\t\tString message = String.format(\"Unable to find build (project: %s, build number: %d)\", \n\t\t\t\t\t\tproject.getPath(), buildNumber);\n\t\t\t\tthrow new EntityNotFoundException(message);\n\t\t\t}\n\t\t\t\n\t\t\tif (!SecurityUtils.canAccessLog(build))\n\t\t\t\tthrow new UnauthorizedException();\n\t\t}\n\t\t\n\t\tResourceResponse response = new ResourceResponse();\n\t\tresponse.setContentType(MimeTypes.OCTET_STREAM);\n\t\t\n\t\tresponse.disableCaching();\n\t\t\n\t\ttry {\n\t\t\tresponse.setFileName(URLEncoder.encode(\"build-log.txt\", StandardCharsets.UTF_8.name()));\n\t\t} catch (UnsupportedEncodingException e) {\n\t\t\tthrow new RuntimeException(e);\n\t\t}\n\t\tresponse.setWriteCallback(new WriteCallback() {\n","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/web/resource/BuildLogResource.java#L44-L80","documentation":"BuildLogResource looks up the build via BuildService.find(project, buildNumber); when no build matches, it throws EntityNotFoundException with \"Unable to find build (project: <path>, build number: <n>)\". The message is a server-side check distinct from a 404 on the project itself — the project loaded fine but the build number does not exist.","triggerScenarios":"GET of the build log resource with a build number that does not exist in the given project — wrong number, build deleted (e.g. after cleaning build history or reducing kept builds), or the project id/path pointing at a different project than intended.","commonSituations":"Bookmarked log links broken after build retention policy pruned old builds; pipeline scripts using a stale build number after re-importing projects; guessing build numbers after a project was recreated (numbers restart at 1).","solutions":["Verify the build number exists: open the project's build list and use a valid number.","Check the project parameter identifies the intended project (build numbers are per-project).","If the build was pruned by retention settings, raise the 'kept builds' limit or archive logs before cleanup."],"exampleFix":"// before\nGET /~resource/buildlogs?project=1&build=999  -> Unable to find build (project: my/app, build number: 999)\n// after\nGET /~resource/buildlogs?project=1&build=42   // use a number present in the build list","handlingStrategy":"validation","validationCode":"// verify the build exists before requesting its log\nconst build = await api.get(`/projects/${projectId}/builds/${buildNumber}`);\nif (!build) throw new Error(`build ${buildNumber} does not exist in project ${projectId}`);","typeGuard":"function buildExists(build) {\n  return build != null && typeof build.number === 'number' && build.status !== undefined;\n}","tryCatchPattern":"try { const log = await fetchBuildLog(project, number); } catch (e) { if (String(e.message).includes('Unable to find build')) console.error('Build pruned or wrong number; list builds first'); else throw e; }","preventionTips":["Look up the build number via the API instead of hardcoding it","Account for build retention policies deleting old builds","Remember build numbers are per-project; verify the project id/path"],"tags":["onedev","http","not-found","ci","build-logs"],"backgroundTag":"entity-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"}