{"record":{"id":"857a850e6d961296","repo":"theonedev/onedev","slug":"unable-to-find-build-project-s-build-number","errorCode":null,"errorMessage":"Unable to find build (project: %s, build number: %d)","messagePattern":"Unable to find build \\(project: (.+?), build number: (.+?)\\)","errorType":"exception","errorClass":"EntityNotFoundException","httpStatus":404,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/web/resource/ArtifactResource.java","lineNumber":70,"sourceCode":"\t\t\tif (pathSegment.length() != 0)\n\t\t\t\tpathSegments.add(pathSegment);\n\t\t}\n\t\t\n\t\tif (pathSegments.isEmpty())\n\t\t\tthrow new ExplicitException(\"Artifact path has to be specified\");\n\t\t\n\t\tString artifactPath = Joiner.on(\"/\").join(pathSegments);\n\t\t\n\t\tFileInfo fileInfo = null;\n\t\tif (!SecurityUtils.isSystem()) {\n\t\t\tProject project = OneDev.getInstance(ProjectService.class).load(projectId);\n\t\t\t\n\t\t\tBuild build = OneDev.getInstance(BuildService.class).find(project, buildNumber);\n\n\t\t\tif (build == null) {\n\t\t\t\tString message = String.format(\"Unable to find build (project: %s, build number: %d)\", \n\t\t\t\t\t\tproject.getPath(), buildNumber);\n\t\t\t\tthrow new EntityNotFoundException(message);\n\t\t\t}\n\t\t\t\n\t\t\tif (!SecurityUtils.canAccessProject(build.getProject()))\n\t\t\t\tthrow new UnauthorizedException();\n\t\t\t\n\t\t\tfileInfo = (FileInfo) getBuildService().getArtifactInfo(build, artifactPath);\n\t\t}\n\t\t\n\t\tResourceResponse response = new ResourceResponse();\n\t\tresponse.getHeaders().addHeader(\"X-Content-Type-Options\", \"nosniff\");\n\t\tresponse.disableCaching();\n\n\t\tString fileName = artifactPath;\n\t\tif (fileName.contains(\"/\"))\n\t\t\tfileName = StringUtils.substringAfterLast(fileName, \"/\");\n\t\ttry {\n\t\t\tresponse.setFileName(URLEncoder.encode(fileName, StandardCharsets.UTF_8.name()));\n\t\t} catch (UnsupportedEncodingException e) {","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/web/resource/ArtifactResource.java#L52-L88","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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"],"exampleFix":"// before\nGET /~resources/artifact?project=3&build=17&path=out.log   // build 17 belongs to project 2\n// after\nGET /~resources/artifact?project=2&build=17&path=out.log","handlingStrategy":"validation","validationCode":"const build = await onedevApi.get(`/builds?project=${projectId}&number=${buildNumber}`);\nif (!build) throw new Error(`Build #${buildNumber} not found in project ${projectId} - verify number and project, or the build was purged`);","typeGuard":null,"tryCatchPattern":"try { await fetch(artifactUrl); } catch (e) { if (e.status === 404) console.error('Build or artifact missing: confirm build number per-project and retention policy'); }","preventionTips":["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"],"tags":["http","not-found","build","artifact"],"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-14T00:17:10.932Z"}