theonedev/onedev · error · BadRequestException
Job not found (project: %s, commit: %s, job: %s)
Error message
Job not found (project: %s, commit: %s, job: %s)
What it means
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.
Source
Thrown at server-core/src/main/java/io/onedev/server/job/DefaultJobService.java:303
JobAuthorizationContext.push(new JobAuthorizationContext(project, commitId, request));
try {
// Lock to guarantee uniqueness of build (by project, commit, job and parameters)
lock.lockInterruptibly();
BuildSpec buildSpec = project.getBuildSpec(commitId);
if (buildSpec == null) {
throw new ExplicitException(String.format(
"Build spec not defined (project: %s, commit: %s)",
project.getPath(), commitId.name()));
}
validateBuildSpec(project, commitId, buildSpec);
if (!buildSpec.getJobMap().containsKey(jobName)) {
var errorMessage = String.format(
"Job not found (project: %s, commit: %s, job: %s)",
project.getPath(), commitId.name(), jobName);
throw new BadRequestException(errorMessage);
}
return doSubmit(user, project, commitId, jobName, paramMap, refName, request, issue, reason);
} catch (Throwable t) {
throw ExceptionUtils.unchecked(t);
} finally {
JobAuthorizationContext.pop();
}
}
private Build doSubmit(User user, Project project, ObjectId commitId, String jobName,
Map<String, List<String>> paramMap, String refName,
@Nullable PullRequest request, @Nullable Issue issue, String reason) {
if (request != null) {
request.setBuildCommitHash(commitId.name());
dao.persist(request);
}
View on GitHub (pinned to d44925c47c)
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.
Example fix
// before
jobService.submit(user, project, commitId, "Build", ...); // job is named 'build'
// after
String jobName = "build";
if (!project.getBuildSpec(commitId).getJobMap().containsKey(jobName))
throw new BadRequestException("Unknown job: " + jobName);
jobService.submit(user, project, commitId, jobName, ...); Defensive patterns
Strategy: validation
Validate before calling
BuildSpec spec = project.getBuildSpec(commitId);
if (spec == null || !spec.getJobMap().containsKey(jobName))
throw new BadRequestException("Job '" + jobName + "' not in spec at " + commitId.name() + "; known: " + (spec == null ? "none" : spec.getJobMap().keySet())); Try / catch
try { jobService.submit(user, project, commitId, jobName, ...); } catch (BadRequestException e) { log.error("{}", e.getMessage()); throw e; } Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Allocated agent not connected to current server, please retr
- Attachment not found:
- Malformed build spec
- This build is not authorized to sync to project:
- Loopback address not allowed for target docker image of push
AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06).
Data as JSON: /api/errors/7e4aad1d1e095e20.
Report an issue: GitHub.