{"record":{"id":"048f6474b57ea58b","repo":"theonedev/onedev","slug":"unable-to-find-build-0-in-project-1","errorCode":null,"errorMessage":"Unable to find build #{0} in project {1}","messagePattern":"Unable to find build #(.+?) in project (.+?)","errorType":"exception","errorClass":"EntityNotFoundException","httpStatus":404,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/web/page/project/builds/detail/BuildDetailPage.java","lineNumber":173,"sourceCode":"\t\tsuper(params);\n\t\t\n\t\tString buildNumberString = params.get(PARAM_BUILD).toString();\n\t\tif (StringUtils.isBlank(buildNumberString))\n\t\t\tthrow new RestartResponseException(ProjectBuildsPage.class, ProjectBuildsPage.paramsOf(getProject(), null, 0));\n\t\t\t\n\t\tbuildModel = new LoadableDetachableModel<Build>() {\n\n\t\t\t@Override\n\t\t\tprotected Build load() {\n\t\t\t\tLong buildNumber;\n\t\t\t\ttry {\n\t\t\t\t\tbuildNumber = Long.valueOf(buildNumberString);\n\t\t\t\t} catch (NumberFormatException e) {\n\t\t\t\t\tthrow new NotAcceptableException(MessageFormat.format(_T(\"Invalid build number: {0}\"), buildNumberString));\n\t\t\t\t}\n\t\t\t\tBuild build = buildService.find(getProject(), buildNumber);\n\t\t\t\tif (build == null)\n\t\t\t\t\tthrow new EntityNotFoundException(MessageFormat.format(_T(\"Unable to find build #{0} in project {1}\"), String.valueOf(buildNumber), getProject()));\n\t\t\t\telse if (!build.getProject().equals(getProject()))\n\t\t\t\t\tthrow new RestartResponseException(getPageClass(), paramsOf(build));\n\t\t\t\telse\n\t\t\t\t\treturn build;\n\t\t\t}\n\n\t\t};\n\t\n\t\tif (!getBuild().isValid())\n\t\t\tthrow new RestartResponseException(InvalidBuildPage.class, InvalidBuildPage.paramsOf(getBuild()));\n\t}\n\t\n\t@Override\n\tpublic Build getBuild() {\n\t\treturn buildModel.getObject();\n\t}\n\t\n\t@Override","sourceCodeStart":155,"sourceCodeEnd":191,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/web/page/project/builds/detail/BuildDetailPage.java#L155-L191","documentation":"OneDev's BuildDetailPage loads the build from the URL parameters in its LoadableDetachableModel. When BuildService.find(project, buildNumber) returns null (no build with that number exists in the project), the page throws EntityNotFoundException with this localized message. It is OneDev's way of turning a nonexistent build reference into a 404-style user-facing error instead of an NPE.","triggerScenarios":"GET a build detail URL /~builds/<buildNumber> where the number parses as a Long but no build with that number exists in the current project (e.g. /~builds/999 when the project only has builds 1-10).","commonSituations":"Stale bookmarks or shared links after the project's builds were cleaned up by a retention policy; a build pruned by 'cleaner' job settings; typo in a link to another project; switching projects while reusing an old URL.","solutions":["Verify the build number exists in the project: Project -> Builds, and correct the URL.","If builds were auto-cleaned, check the project's 'Builds Cleanup' rules and restore from backup or rerun the job to regenerate the build.","Use the build's reference like 'project-key#123' via OneDev's search to locate the correct project/number combination.","Check user access: a build in another project will not be found via this project's URL; open it under the owning project."],"exampleFix":"// before\nGET /projects/my-app/~builds/999\n// after\nGET /projects/my-app/~builds/12","handlingStrategy":"try-catch","validationCode":"long buildNumber = Long.parseLong(numberStr);\nboolean exists = buildService.find(project, buildNumber) != null;\nif (!exists) throw new IllegalArgumentException(\"Build #\" + buildNumber + \" does not exist in \" + project.getName());","typeGuard":null,"tryCatchPattern":"try {\n    Build b = buildService.find(project, buildNumber);\n    if (b == null) { /* show 404 / friendly message */ }\n} catch (EntityNotFoundException e) {\n    logger.warn(\"Build {} not found in {}\", buildNumber, project); // render not-found page\n}","preventionTips":["Resolve builds via project key references (projectKey#number) rather than hand-built URLs.","Check build cleanup rules before assuming old build links remain valid.","Validate build numbers exist in the target project before sharing links."],"tags":["onedev","build","rest-url","entity-not-found"],"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"}