theonedev/onedev · error · NotAcceptableException
No default branch in project:
Error message
No default branch in project:
What it means
Thrown by RunProjectJobAction.execute when the target project has no default branch configured. A RunProjectJobAction with no explicit branch/tag resolves the project's default branch to run the job against; if the project is empty or has no default branch set, OneDev throws this NotAcceptableException to abort the action.
Source
Thrown at server-core/src/main/java/io/onedev/server/buildspec/job/action/RunProjectJobAction.java:216
if (accessToken == null)
throw new NotAcceptableException("Invalid access token");
var subject = accessToken.asSubject();
if (!SecurityUtils.canRunJob(subject, project, jobName))
throw new UnauthorizedException();
var user = SecurityUtils.getUser(subject);
ThreadContext.bind(subject);
try {
String refName;
if (branch != null) {
refName = GitUtils.branch2ref(branch);
} else if (tag != null) {
refName = GitUtils.tag2ref(tag);
} else {
var defaultBranch = project.getDefaultBranch();
if (defaultBranch == null)
throw new NotAcceptableException("No default branch in project: " + project.getPath());
refName = GitUtils.branch2ref(defaultBranch);
}
var commit = project.getRevCommit(refName, false);
if (commit == null)
throw new NotAcceptableException("Ref not found (project: " + project.getPath() + ", ref: " + refName + ")");
Map<String, List<String>> jobParamMap = new HashMap<>();
for (var jobParam: jobParams) {
jobParamMap.computeIfAbsent(jobParam.getName(), k -> new ArrayList<>()).add(jobParam.getValue());
}
getJobService().submit(user, project, commit.copy(), jobName, jobParamMap, refName, null, null,
"Triggered via post build action of job '" + build.getJobName() + "' in project '" + build.getProject().getPath() + "'");
} finally {
ThreadContext.unbindSubject();
}
}
View on GitHub (pinned to d44925c47c)
Solutions
- Set a default branch for the target project (Project -> Branches / default branch setting).
- Push at least one commit to the target project so a branch exists.
- Explicitly specify a 'branch' or 'tag' in the RunProjectJobAction so it doesn't rely on the default branch.
- Verify the project path in the action points to the intended, non-empty project.
Example fix
// before (buildspec.yml) actions: - type: RunProjectJob project: my-sub-project // after actions: - type: RunProjectJob project: my-sub-project branch: main
Defensive patterns
Strategy: validation
Validate before calling
if (project.getDefaultBranch() == null) {
throw new IllegalStateException("Target project '" + project.getPath() + "' has no default branch; set one or specify branch in the action");
} Try / catch
try {
runProjectJobAction.execute(build, context);
} catch (NotAcceptableException e) {
if (e.getMessage().startsWith("No default branch in project")) {
// surface a config-fix hint to the pipeline author
} else throw e;
} Prevention
- Always set a default branch immediately after project creation.
- Push an initial commit before wiring run-project actions to a new project.
- Prefer explicit branch/tag in RunProjectJobAction over relying on defaults.
When it happens
Trigger: A run-project job action targets a project whose branch/tag are both null and project.getDefaultBranch() returns null — e.g. an empty repository, or a project whose default branch was deleted or never set.
Common situations: Configuring a pipeline in a newly created empty project; renaming/deleting the default branch without updating project settings; referencing another project that hasn't had its first push yet.
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
- Ref not found (project:
- Malformed build spec (import project: {0}, import revision:
- Build spec not defined (import project: {0}, import revision
- Error validating issue fields:
- Error validating job parameters (job: %s, error message: %s)
AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06).
Data as JSON: /api/errors/05befdda42d74481.
Report an issue: GitHub.