theonedev/onedev · error · EntityNotFoundException
Unable to find build #{0} in project {1}
Error message
Unable to find build #{0} in project {1} What it means
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.
Source
Thrown at server-core/src/main/java/io/onedev/server/web/page/project/builds/detail/BuildDetailPage.java:173
super(params);
String buildNumberString = params.get(PARAM_BUILD).toString();
if (StringUtils.isBlank(buildNumberString))
throw new RestartResponseException(ProjectBuildsPage.class, ProjectBuildsPage.paramsOf(getProject(), null, 0));
buildModel = new LoadableDetachableModel<Build>() {
@Override
protected Build load() {
Long buildNumber;
try {
buildNumber = Long.valueOf(buildNumberString);
} catch (NumberFormatException e) {
throw new NotAcceptableException(MessageFormat.format(_T("Invalid build number: {0}"), buildNumberString));
}
Build build = buildService.find(getProject(), buildNumber);
if (build == null)
throw new EntityNotFoundException(MessageFormat.format(_T("Unable to find build #{0} in project {1}"), String.valueOf(buildNumber), getProject()));
else if (!build.getProject().equals(getProject()))
throw new RestartResponseException(getPageClass(), paramsOf(build));
else
return build;
}
};
if (!getBuild().isValid())
throw new RestartResponseException(InvalidBuildPage.class, InvalidBuildPage.paramsOf(getBuild()));
}
@Override
public Build getBuild() {
return buildModel.getObject();
}
@OverrideView on GitHub (pinned to d44925c47c)
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.
Example fix
// before GET /projects/my-app/~builds/999 // after GET /projects/my-app/~builds/12
Defensive patterns
Strategy: try-catch
Validate before calling
long buildNumber = Long.parseLong(numberStr);
boolean exists = buildService.find(project, buildNumber) != null;
if (!exists) throw new IllegalArgumentException("Build #" + buildNumber + " does not exist in " + project.getName()); Try / catch
try {
Build b = buildService.find(project, buildNumber);
if (b == null) { /* show 404 / friendly message */ }
} catch (EntityNotFoundException e) {
logger.warn("Build {} not found in {}", buildNumber, project); // render not-found page
} Prevention
- 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.
When it happens
Trigger: 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).
Common situations: 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.
Understand the failure class
Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.
Related errors
- Unable to find build #{0} in project {1}
- Unable to find build:
- No current build in query context
- No build in query context
- No build in query context
AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06).
Data as JSON: /api/errors/048f6474b57ea58b.
Report an issue: GitHub.