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

MarkdownReportDownloadResource looks up the build via BuildService.find(project, buildNumber); if absent it throws EntityNotFoundException with a formatted 'Unable to find build (project: %s, build number: %d)' message. Same semantics as the HTML report resource: the requested build does not exist for the given project.

Source

Thrown at server-plugin/server-plugin-report-markdown/src/main/java/io/onedev/server/plugin/report/markdown/MarkdownReportDownloadResource.java:53

	
	@Override
	protected ResourceResponse newResourceResponse(Attributes attributes) {
		PageParameters params = attributes.getParameters();

		String projectPath = params.get(PARAM_PROJECT).toString();
		Project project = OneDev.getInstance(ProjectService.class).findByPath(projectPath);
		
		Long buildNumber = params.get(PARAM_BUILD).toOptionalLong();
		
		if (buildNumber == null)
			throw new IllegalArgumentException("build number has to be specified");
		
		Build build = OneDev.getInstance(BuildService.class).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);
		}
		
		String reportName = params.get(PARAM_REPORT).toOptionalString();
		
		if (reportName == null)
			throw new IllegalArgumentException("Markdown report name has to be specified");
		if (reportName.contains(".."))
			throw new ExplicitException("Invalid request path");
		
		if (!SecurityUtils.canAccessReport(build, reportName))
			throw new UnauthorizedException();
			
		List<String> pathSegments = new ArrayList<>();
		for (int i = 0; i < params.getIndexedCount(); i++) {
			String pathSegment = params.get(i).toString();
			if (pathSegment.contains(".."))
				throw new ExplicitException("Invalid request path");
			if (pathSegment.length() != 0)

View on GitHub (pinned to d44925c47c)

Solutions

  1. Verify project path and build number in the request
  2. Check the build was not deleted by retention rules; use an existing build
  3. Regenerate the report link from a live build

Example fix

// before
GET /~resources/markdown-report/proj/9999/report/notes  // build 9999 deleted
// after
GET /~resources/markdown-report/proj/1043/report/notes
Defensive patterns

Strategy: validation

Validate before calling

Build build = OneDev.getInstance(BuildService.class).find(project, buildNumber);
if (build == null) throw new IllegalArgumentException("Build not found: " + projectPath + "#" + buildNumber);

Type guard

function buildExists(project, buildNumber) {
  return OneDev.getInstance(BuildService.class).find(project, buildNumber) != null;
}

Try / catch

try { fetch(url); } catch (EntityNotFoundException e) { // look up latest build and rebuild URL }

Prevention

When it happens

Trigger: GET with valid build-number format but a number that has no matching build in the project (deleted build, wrong project path, typo).

Common situations: Retention/pruning removed the build; cross-project links with mismatched project path; URL copied from another environment.

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


AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06). Data as JSON: /api/errors/4ac2f5bfb7609378. Report an issue: GitHub.