{"record":{"id":"7e4aad1d1e095e20","repo":"theonedev/onedev","slug":"job-not-found-project-s-commit-s-job-s","errorCode":null,"errorMessage":"Job not found (project: %s, commit: %s, job: %s)","messagePattern":"Job not found \\(project: (.+?), commit: (.+?), job: (.+?)\\)","errorType":"exception","errorClass":"BadRequestException","httpStatus":null,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/job/DefaultJobService.java","lineNumber":303,"sourceCode":"\t\tJobAuthorizationContext.push(new JobAuthorizationContext(project, commitId, request));\n\t\ttry {\n\t\t\t// Lock to guarantee uniqueness of build (by project, commit, job and parameters)\n\t\t\tlock.lockInterruptibly();\n\n\t\t\tBuildSpec buildSpec = project.getBuildSpec(commitId);\n\t\t\tif (buildSpec == null) {\n\t\t\t\tthrow new ExplicitException(String.format(\n\t\t\t\t\t\t\"Build spec not defined (project: %s, commit: %s)\",\n\t\t\t\t\t\tproject.getPath(), commitId.name()));\n\t\t\t}\n\n\t\t\tvalidateBuildSpec(project, commitId, buildSpec);\n\n\t\t\tif (!buildSpec.getJobMap().containsKey(jobName)) {\n\t\t\t\tvar errorMessage = String.format(\n\t\t\t\t\t\t\"Job not found (project: %s, commit: %s, job: %s)\",\n\t\t\t\t\t\tproject.getPath(), commitId.name(), jobName);\n\t\t\t\tthrow new BadRequestException(errorMessage);\n\t\t\t}\n\n\t\t\treturn doSubmit(user, project, commitId, jobName, paramMap, refName, request, issue, reason);\n\t\t} catch (Throwable t) {\n\t\t\tthrow ExceptionUtils.unchecked(t);\n\t\t} finally {\n\t\t\tJobAuthorizationContext.pop();\n\t\t}\n\t}\n\n\tprivate Build doSubmit(User user, Project project, ObjectId commitId, String jobName,\n\t\t\t\t\t\t   Map<String, List<String>> paramMap, String refName, \n\t\t\t\t\t\t   @Nullable PullRequest request, @Nullable Issue issue, String reason) {\n\t\tif (request != null) {\n\t\t\trequest.setBuildCommitHash(commitId.name());\n\t\t\tdao.persist(request);\n\t\t}\n\t\t","sourceCodeStart":285,"sourceCodeEnd":321,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/job/DefaultJobService.java#L285-L321","documentation":"After loading and validating the build spec, DefaultJobService.submit checks that the requested job name exists in the spec's job map. If buildSpec.getJobMap() has no entry for jobName, a BadRequestException listing project, commit, and job name is thrown before any build is created.","triggerScenarios":"submit/run/build with a jobName that is not one of the keys defined under 'jobs:' in .onedev-buildspec at that commit — e.g. renamed jobs, typos, or a spec on that branch that differs from the one the job name came from.","commonSituations":"Job renamed in the build spec while external scripts/cron still reference the old name; submitting against a different branch whose spec defines different jobs; case-sensitive job name mismatch.","solutions":["Confirm the exact job name in .onedev-buildspec at the given commit and use it (names are case-sensitive).","Fetch the spec's job names programmatically (project.getBuildSpec(commitId).getJobMap().keySet()) before submitting.","Update any external triggers (scripts, schedules, webhooks) still referencing the old job name."],"exampleFix":"// before\njobService.submit(user, project, commitId, \"Build\", ...); // job is named 'build'\n// after\nString jobName = \"build\";\nif (!project.getBuildSpec(commitId).getJobMap().containsKey(jobName))\n    throw new BadRequestException(\"Unknown job: \" + jobName);\njobService.submit(user, project, commitId, jobName, ...);","handlingStrategy":"validation","validationCode":"BuildSpec spec = project.getBuildSpec(commitId);\nif (spec == null || !spec.getJobMap().containsKey(jobName))\n  throw new BadRequestException(\"Job '\" + jobName + \"' not in spec at \" + commitId.name() + \"; known: \" + (spec == null ? \"none\" : spec.getJobMap().keySet()));","typeGuard":null,"tryCatchPattern":"try { jobService.submit(user, project, commitId, jobName, ...); } catch (BadRequestException e) { log.error(\"{}\", e.getMessage()); throw e; }","preventionTips":["Look up job names from the spec at the exact commit instead of hardcoding","Keep external trigger scripts in sync with job renames","Respect case sensitivity of job names"],"tags":["ci","job-name","invalid-argument"],"backgroundTag":"resource-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"}