theonedev/onedev · error · NotAcceptableException
Ref not found (project:
Error message
Ref not found (project:
What it means
Thrown by RunProjectJobAction.execute when the resolved ref (explicit branch/tag, or the default branch) does not exist in the target repository. getRevCommit returns null for the refName, so OneDev raises this NotAcceptableException including the project path and ref name.
Source
Thrown at server-core/src/main/java/io/onedev/server/buildspec/job/action/RunProjectJobAction.java:221
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();
}
}
@Override
public boolean isValid(ConstraintValidatorContext context) {
if (branch != null && tag != null) {
var errorMessage = "Either branch or tag can be specified, but not both";
context.buildConstraintViolationWithTemplate(errorMessage)View on GitHub (pinned to d44925c47c)
Solutions
- Check the branch/tag spelling in the RunProjectJobAction against branches that actually exist in the target project.
- List the target project's branches/tags in the UI and pick an existing one.
- Ensure the target repository has received the branch/tag (push it if missing).
- If relying on the default branch, confirm that default branch still exists.
Example fix
// before actions: - type: RunProjectJob project: my-sub-project branch: release/1.0 // after (branch actually exists) actions: - type: RunProjectJob project: my-sub-project branch: release/2.0
Defensive patterns
Strategy: validation
Validate before calling
String ref = branch != null ? GitUtils.branch2ref(branch)
: tag != null ? GitUtils.tag2ref(tag)
: GitUtils.branch2ref(project.getDefaultBranch());
if (project.getRevCommit(ref, false) == null)
throw new IllegalArgumentException("Ref '" + ref + "' does not exist in project " + project.getPath()); Try / catch
try {
action.execute(build, context);
} catch (NotAcceptableException e) {
if (e.getMessage().startsWith("Ref not found")) {
// log project+ref from message and fall back to a known-good branch
} else throw e;
} Prevention
- Verify branch/tag names against the target repository before committing the buildspec.
- Use the branch/tag picker UI rather than free text.
- Watch for branch renames/deletes that invalidate cross-project references.
When it happens
Trigger: RunProjectJobAction with a 'branch' or 'tag' value that doesn't exist in the target project's repository; also when the project's default branch was deleted after being configured.
Common situations: Typo in the branch or tag name in the buildspec; branch was renamed or deleted on the target repo; targeting a tag that hasn't been pushed; stale references after repository cleanup.
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
- No default branch in 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/ee8a0f9dec5f290c.
Report an issue: GitHub.