theonedev/onedev · error · EntityNotFoundException
Unable to find build (project: %s, build number: %d)
Error message
Unable to find build (project: %s, build number: %d)
What it means
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.
Source
Thrown at server-core/src/main/java/io/onedev/server/web/resource/BuildLogResource.java:62
private static final String PARAM_BUILD = "build";
@Override
protected ResourceResponse newResourceResponse(Attributes attributes) {
PageParameters params = attributes.getParameters();
Long projectId = params.get(PARAM_PROJECT).toLong();
Long buildNumber = params.get(PARAM_BUILD).toOptionalLong();
if (buildNumber == null)
throw new IllegalArgumentException("build number has to be specified");
if (!SecurityUtils.isSystem()) {
Project project = getProjectService().load(projectId);
Build build = getBuildService().find(project, buildNumber);
if (build == null) {
String message = String.format("Unable to find build (project: %s, build number: %d)",
project.getPath(), buildNumber);
throw new EntityNotFoundException(message);
}
if (!SecurityUtils.canAccessLog(build))
throw new UnauthorizedException();
}
ResourceResponse response = new ResourceResponse();
response.setContentType(MimeTypes.OCTET_STREAM);
response.disableCaching();
try {
response.setFileName(URLEncoder.encode("build-log.txt", StandardCharsets.UTF_8.name()));
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
response.setWriteCallback(new WriteCallback() {
View on GitHub (pinned to d44925c47c)
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.
Example fix
// before GET /~resource/buildlogs?project=1&build=999 -> Unable to find build (project: my/app, build number: 999) // after GET /~resource/buildlogs?project=1&build=42 // use a number present in the build list
Defensive patterns
Strategy: validation
Validate before calling
// verify the build exists before requesting its log
const build = await api.get(`/projects/${projectId}/builds/${buildNumber}`);
if (!build) throw new Error(`build ${buildNumber} does not exist in project ${projectId}`); Type guard
function buildExists(build) {
return build != null && typeof build.number === 'number' && build.status !== undefined;
} Try / catch
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; } Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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).
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
- build number has to be specified
- Unauthorized
- Iteration '${iterationName}' not found
- Link spec not found: ${linkName}
- Pull request not found:
AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06).
Data as JSON: /api/errors/c8a095a65c9e869f.
Report an issue: GitHub.