{"record":{"id":"bfa53db0a8ceab61","repo":"theonedev/onedev","slug":"unable-to-find-build-value","errorCode":null,"errorMessage":"Unable to find build: ${value}","messagePattern":"Unable to find build: (.+?)","errorType":"exception","errorClass":"NotFoundException","httpStatus":404,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/util/QueryUtils.java","lineNumber":170,"sourceCode":"\t\t\tthrow new NotFoundException(\"Unable to find issue: \" + value);\n\t}\n\t\n\tpublic static PullRequest getPullRequest(@Nullable Project project, String value) {\n\t\tvar reference = PullRequestReference.of(value, project);\n\t\tvar pullRequest = OneDev.getInstance(PullRequestService.class).find(reference.getProject(), reference.getNumber());\n\t\tif (pullRequest != null)\n\t\t\treturn pullRequest;\n\t\telse\n\t\t\tthrow new NotFoundException(\"Unable to find pull request: \" + value);\n\t}\n\t\n\tpublic static Build getBuild(@Nullable Project project, String value) {\n\t\tvar reference = BuildReference.of(value, project);\n\t\tvar build = OneDev.getInstance(BuildService.class).find(reference.getProject(), reference.getNumber());\n\t\tif (build != null)\n\t\t\treturn build;\n\t\telse\n\t\t\tthrow new NotFoundException(\"Unable to find build: \" + value);\n\t}\n\n\tpublic static Long getNumber(String value) {\n\t\tif (value.startsWith(\"#\"))\n\t\t\tvalue = value.substring(1);\n\t\ttry {\n\t\t\treturn Long.parseLong(value);\n\t\t} catch (NumberFormatException e) {\n\t\t\tthrow new NotAcceptableException(\"Invalid number: \" + value);\n\t\t}\n\t}\n\t\n\tpublic static Iteration getIteration(@Nullable Project project, String value) {\n\t\tif (project != null && !value.contains(\":\")) \n\t\t\tvalue = project.getPath() + \":\" + value;\n\t\tIteration iteration = OneDev.getInstance(IterationService.class).findInHierarchy(value);\n\t\tif (iteration != null)\n\t\t\treturn iteration;","sourceCodeStart":152,"sourceCodeEnd":188,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/util/QueryUtils.java#L152-L188","documentation":"QueryUtils.getBuild resolves a build reference (e.g. '#100' or 'project#100') to a Build entity via BuildService.find. If no build with that number exists in the referenced project, a NotFoundException 'Unable to find build' is thrown.","triggerScenarios":"Calling QueryUtils.getBuild with a build number that does not exist in the target project; missing project prefix when project is null; number belongs to a different project than the referenced one.","commonSituations":"Query criteria referencing build numbers from another project; build numbers that never ran in that project; projects where builds were purged; typos or confusing issue/PR numbers with build numbers.","solutions":["Verify the build number exists in the specified project (check the build URL in OneDev)","Add the project scope to the reference (e.g. 'group/project#100') or pass the correct default Project","Confirm the number is a build number, not an issue or PR number","Update saved queries when builds are purged or the project path changes"],"exampleFix":"// before\nBuild build = QueryUtils.getBuild(null, \"#100\");\n// after\nBuild build = QueryUtils.getBuild(project, \"group/my-project#100\");","handlingStrategy":"try-catch","validationCode":"if (!value.matches(\"(#\\\\d+|[^#]+#\\\\d+)\"))\n    throw new UserException(\"Build reference must look like '#100' or 'project#100'\");","typeGuard":"boolean isBuildReference(String s) {\n    return s != null && s.matches(\"(#\\\\d+|[^#]+#\\\\d+)\");\n}","tryCatchPattern":"try {\n    Build build = QueryUtils.getBuild(project, value);\n} catch (NotFoundException e) {\n    logger.warn(\"Build not found: {}\", value);\n}","preventionTips":["Scope build references with the project path","Remember build numbers are per-project, so never reuse numbers across projects in queries","Update queries after build purge policies remove old builds"],"tags":["build","lookup","not-found","onedev"],"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-14T05:17:10.506Z"}