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
ArtifactResource resolves the build via BuildService.find(project, buildNumber); when no build with that number exists in the given project it throws EntityNotFoundException with this formatted message naming the project path and build number. Build numbers are per-project sequences, so the same number can exist in other projects.
Source
Thrown at server-core/src/main/java/io/onedev/server/web/resource/ArtifactResource.java:70
if (pathSegment.length() != 0)
pathSegments.add(pathSegment);
}
if (pathSegments.isEmpty())
throw new ExplicitException("Artifact path has to be specified");
String artifactPath = Joiner.on("/").join(pathSegments);
FileInfo fileInfo = null;
if (!SecurityUtils.isSystem()) {
Project project = OneDev.getInstance(ProjectService.class).load(projectId);
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);
}
if (!SecurityUtils.canAccessProject(build.getProject()))
throw new UnauthorizedException();
fileInfo = (FileInfo) getBuildService().getArtifactInfo(build, artifactPath);
}
ResourceResponse response = new ResourceResponse();
response.getHeaders().addHeader("X-Content-Type-Options", "nosniff");
response.disableCaching();
String fileName = artifactPath;
if (fileName.contains("/"))
fileName = StringUtils.substringAfterLast(fileName, "/");
try {
response.setFileName(URLEncoder.encode(fileName, StandardCharsets.UTF_8.name()));
} catch (UnsupportedEncodingException e) {View on GitHub (pinned to d44925c47c)
Solutions
- Verify the build number exists in that exact project via the OneDev UI (Project > Builds) and correct the URL
- Check the project id in the URL matches the project whose build you intend
- If the build was deleted by retention settings, adjust build retention/cleanup policy or re-run the pipeline
- If scripting, query the build via OneDev API to resolve the number dynamically instead of hardcoding
Example fix
// before GET /~resources/artifact?project=3&build=17&path=out.log // build 17 belongs to project 2 // after GET /~resources/artifact?project=2&build=17&path=out.log
Defensive patterns
Strategy: validation
Validate before calling
const build = await onedevApi.get(`/builds?project=${projectId}&number=${buildNumber}`);
if (!build) throw new Error(`Build #${buildNumber} not found in project ${projectId} - verify number and project, or the build was purged`); Try / catch
try { await fetch(artifactUrl); } catch (e) { if (e.status === 404) console.error('Build or artifact missing: confirm build number per-project and retention policy'); } Prevention
- Resolve build numbers via API/variables instead of hardcoding
- Distinguish build number (per project) from build id (global)
- Check retention/cleanup rules before referencing old builds
When it happens
Trigger: Requesting an artifact for a build number that does not exist in the specified project (wrong number, wrong project id, or build deleted after retention/cleanup).
Common situations: Copy-pasting a URL across projects while keeping the old build number; referencing a build purged by retention policy; off-by-one using a run counter instead of the OneDev build number; using the build id instead of the build number.
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 not found: ${referenceString}
- No project found with path '${projectPath}'
- Unable to find build:
- Unable to find build: ${value}
- Artifact path has to be specified
AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06).
Data as JSON: /api/errors/857a850e6d961296.
Report an issue: GitHub.