{"record":{"id":"ee8a0f9dec5f290c","repo":"theonedev/onedev","slug":"ref-not-found-project","errorCode":null,"errorMessage":"Ref not found (project: ","messagePattern":"Ref not found \\(project: ","errorType":"http","errorClass":"NotAcceptableException","httpStatus":400,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/buildspec/job/action/RunProjectJobAction.java","lineNumber":221,"sourceCode":"\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\n\t@Override\n\tpublic boolean isValid(ConstraintValidatorContext context) {\n\t\tif (branch != null && tag != null) {\n\t\t\tvar errorMessage = \"Either branch or tag can be specified, but not both\";\n\t\t\tcontext.buildConstraintViolationWithTemplate(errorMessage)","sourceCodeStart":203,"sourceCodeEnd":239,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/buildspec/job/action/RunProjectJobAction.java#L203-L239","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nactions:\n- type: RunProjectJob\n  project: my-sub-project\n  branch: release/1.0\n\n// after (branch actually exists)\nactions:\n- type: RunProjectJob\n  project: my-sub-project\n  branch: release/2.0","handlingStrategy":"validation","validationCode":"String ref = branch != null ? GitUtils.branch2ref(branch)\n        : tag != null ? GitUtils.tag2ref(tag)\n        : GitUtils.branch2ref(project.getDefaultBranch());\nif (project.getRevCommit(ref, false) == null)\n    throw new IllegalArgumentException(\"Ref '\" + ref + \"' does not exist in project \" + project.getPath());","typeGuard":null,"tryCatchPattern":"try {\n    action.execute(build, context);\n} catch (NotAcceptableException e) {\n    if (e.getMessage().startsWith(\"Ref not found\")) {\n        // log project+ref from message and fall back to a known-good branch\n    } else throw e;\n}","preventionTips":["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."],"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-14T00:17:10.932Z"}