{"record":{"id":"05befdda42d74481","repo":"theonedev/onedev","slug":"no-default-branch-in-project","errorCode":null,"errorMessage":"No default branch in project: ","messagePattern":"No default branch in project: ","errorType":"http","errorClass":"NotAcceptableException","httpStatus":400,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/buildspec/job/action/RunProjectJobAction.java","lineNumber":216,"sourceCode":"\t\tif (accessToken == null)\n\t\t\tthrow new NotAcceptableException(\"Invalid access token\");\n\t\t\n\t\tvar subject = accessToken.asSubject();\n\t\tif (!SecurityUtils.canRunJob(subject, project, jobName))\t\t\n\t\t\tthrow new UnauthorizedException();\n\n\t\tvar user = SecurityUtils.getUser(subject);\n\t\tThreadContext.bind(subject);\n\t\ttry {\n\t\t\tString refName;\n\t\t\tif (branch != null) {\n\t\t\t\trefName = GitUtils.branch2ref(branch);\n\t\t\t} else if (tag != null) {\n\t\t\t\trefName = GitUtils.tag2ref(tag);\n\t\t\t} else {\n\t\t\t\tvar defaultBranch = project.getDefaultBranch();\n\t\t\t\tif (defaultBranch == null)\n \t\t\t\t\tthrow new NotAcceptableException(\"No default branch in project: \" + project.getPath());\n\t\t\t\trefName = GitUtils.branch2ref(defaultBranch);\n\t\t\t}\n\t\t\tvar commit = project.getRevCommit(refName, false);\n\t\t\tif (commit == null)\n\t\t\t\tthrow new NotAcceptableException(\"Ref not found (project: \" + project.getPath() + \", ref: \" + refName + \")\");\n\t\t\t\t\t\t\n\t\t\tMap<String, List<String>> jobParamMap = new HashMap<>();\n\t\t\tfor (var jobParam: jobParams) {\n\t\t\t\tjobParamMap.computeIfAbsent(jobParam.getName(), k -> new ArrayList<>()).add(jobParam.getValue());\n\t\t\t}\n\t\t\t\n\t\t\tgetJobService().submit(user, project, commit.copy(), jobName, jobParamMap, refName, null, null, \n\t\t\t\t\t\"Triggered via post build action of job '\" + build.getJobName() + \"' in project '\" + build.getProject().getPath() + \"'\");\n\t\t} finally {\n\t\t\tThreadContext.unbindSubject();\n\t\t}\t\t\n\t}\n","sourceCodeStart":198,"sourceCodeEnd":234,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/buildspec/job/action/RunProjectJobAction.java#L198-L234","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before (buildspec.yml)\nactions:\n- type: RunProjectJob\n  project: my-sub-project\n\n// after\nactions:\n- type: RunProjectJob\n  project: my-sub-project\n  branch: main","handlingStrategy":"validation","validationCode":"if (project.getDefaultBranch() == null) {\n    throw new IllegalStateException(\"Target project '\" + project.getPath() + \"' has no default branch; set one or specify branch in the action\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    runProjectJobAction.execute(build, context);\n} catch (NotAcceptableException e) {\n    if (e.getMessage().startsWith(\"No default branch in project\")) {\n        // surface a config-fix hint to the pipeline author\n    } else throw e;\n}","preventionTips":["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."],"tags":["onedev","git","ci-config","buildspec"],"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-14T05:17:10.506Z"}