{"record":{"id":"21964c28f6aa4056","repo":"theonedev/onedev","slug":"job-not-found-21964c","errorCode":null,"errorMessage":"Job not found","messagePattern":"Job not found","errorType":"exception","errorClass":"ExplicitException","httpStatus":null,"severity":"warning","filePath":"server-core/src/main/java/io/onedev/server/job/DefaultJobService.java","lineNumber":1375,"sourceCode":"\n\t@Transactional\n\t@Listen\n\tpublic void on(BuildFinished event) {\n\t\tBuild build = event.getBuild();\n\t\tJobAuthorizationContext.push(build.getJobAuthorizationContext());\n\t\tBuild.push(build);\n\t\ttry {\n\t\t\tJobVariableInterpolator interpolator = new JobVariableInterpolator(build, build.getParamCombination());\n\t\t\tMap<String, String> placeholderValues = new HashMap<>();\n\t\t\tplaceholderValues.put(BUILD_VERSION, build.getVersion());\n\t\t\tif (build.getJob() != null) {\n\t\t\t\tfor (PostBuildAction action : build.getJob().getPostBuildActions()) {\n\t\t\t\t\taction = interpolator.interpolateProperties(action);\n\t\t\t\t\tif (ActionCondition.parse(build.getJob(), action.getCondition()).matches(build))\n\t\t\t\t\t\taction.execute(build);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthrow new ExplicitException(\"Job not found\");\n\t\t\t}\n\t\t} catch (Throwable e) {\n\t\t\tString message = String.format(\"Error processing post build actions (project: %s, commit: %s, job: %s)\",\n\t\t\t\t\tbuild.getProject().getPath(), build.getCommitHash(), build.getJobName());\n\t\t\tlogException(message, e);\n\t\t} finally {\n\t\t\tBuild.pop();\n\t\t\tJobAuthorizationContext.pop();\n\t\t}\n\t}\n\n\t@Override\n\tpublic boolean canPullCode(HttpServletRequest request, Project project) {\n\t\tString jobToken = SecurityUtils.getBearerToken(request);\n\t\tif (jobToken != null) {\n\t\t\tJobContext jobContext = getJobContext(jobToken, false);\n\t\t\tif (jobContext != null)\n\t\t\t\treturn jobContext.getProjectId().equals(project.getId());","sourceCodeStart":1357,"sourceCodeEnd":1393,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/job/DefaultJobService.java#L1357-L1393","documentation":"Thrown during post-build action processing when build.getJob() returns null — the job definition (e.g. from .onedev-buildspec or job registry) is no longer resolvable for the finished build. The error is caught immediately by the surrounding catch block and only logged as 'Error processing post build actions', so post-build actions are skipped.","triggerScenarios":"Executing build.getJob().getPostBuildActions() after the build finished when the job definition cannot be found — e.g. the build spec was removed/renamed, or the job cache entry was evicted before post-build ran.","commonSituations":"Branch deleted or .onedev-buildspec changed/removed while build was running; project restructure during the run; server restart between job completion and post-build handling.","solutions":["Ensure the build spec/job definition still exists at the commit when the build completes","Re-run the build with the current job definition","Check the logged 'Error processing post build actions' message to confirm project/commit/job name","Avoid deleting jobs or build specs while builds are in flight"],"exampleFix":"// before (implicit assumption)\nfor (PostBuildAction action : build.getJob().getPostBuildActions()) { ... }\n// after (guard)\nvar job = build.getJob();\nif (job != null)\n    for (PostBuildAction action : job.getPostBuildActions()) { ... }","handlingStrategy":"try-catch","validationCode":"var job = build.getJob();\nif (job == null) {\n    log.warn(\"Job definition unavailable for post build actions (build {})\", build.getId());\n    return;\n}","typeGuard":null,"tryCatchPattern":"try {\n    for (PostBuildAction action : build.getJob().getPostBuildActions()) { action.execute(build); }\n} catch (Exception e) {\n    log.error(\"Error processing post build actions\", e);\n}","preventionTips":["Do not delete/rewrite build specs while builds are running","Ensure build specs are committed before triggering builds","Treat post-build actions as best-effort and log failures"],"tags":["ci","post-build","job-definition"],"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-14T05:17:10.506Z"}