{"record":{"id":"2654acda5353f90e","repo":"theonedev/onedev","slug":"issue-issuereference-is-not-in-current-project","errorCode":null,"errorMessage":"Issue ${issueReference} is not in current project","messagePattern":"Issue (.+?) is not in current project","errorType":"http","errorClass":"NotAcceptableException","httpStatus":406,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/ai/TodResource.java","lineNumber":701,"sourceCode":"\n        var fieldValues = FieldUtils.getFieldValues(subject, issue.getProject(), data);\n        issueChangeService.changeState(user, issue, state, fieldValues, transition.getPromptFields(),\n                transition.getRemoveFields(), comment);\n        return IssueHelper.getDetail(currentProject, issue);\n    }\n\n    @Path(\"/ensure-issue-branch\") \n    @POST\n    public String ensureIssueBranch(\n                @QueryParam(\"currentProject\") @NotNull String currentProjectPath, \n                @QueryParam(\"reference\") @NotNull String issueReference) {\n        var subject = SecurityUtils.getSubject();\n\n        var currentProject = getProject(currentProjectPath);\n        var issue = getIssue(currentProject, issueReference);\n\n        if (!issue.getProject().equals(currentProject))\n            throw new NotAcceptableException(\"Issue \" + issueReference + \" is not in current project\");\n\n        return issueService.ensureBranch(subject, issue);\n    }\n\n    @Path(\"/link-issues\")\n    @GET\n    public Map<String, Object> linkIssues(\n                @QueryParam(\"currentProject\") @NotNull String currentProjectPath, \n                @QueryParam(\"sourceReference\") @NotNull String sourceReference, \n                @QueryParam(\"linkName\") @Nullable String linkName, \n                @QueryParam(\"targetReference\") @NotNull String targetReference) {\n        if (SecurityUtils.getUser() == null)\n            throw new UnauthenticatedException();\n\n        var currentProject = getProject(currentProjectPath);\n\n        var sourceIssue = getIssue(currentProject, sourceReference);\n        var targetIssue = getIssue(currentProject, targetReference);","sourceCodeStart":683,"sourceCodeEnd":719,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/ai/TodResource.java#L683-L719","documentation":"Thrown as NotAcceptableException when creating an issue branch: the resolved issue belongs to a different project than the currentProject parameter. OneDev requires the issue and the target project for the branch to match.","triggerScenarios":"Calling the AI tod ensure-branch endpoint with currentProject=A and an issue reference that resolves to an issue in project B.","commonSituations":"Agent passes the wrong currentProject query parameter; issue reference copied from a different project's board; cross-project issue numbering confusion (issue numbers collide across projects).","solutions":["Pass the currentProject matching the project the issue actually belongs to.","Use the issue's full reference (e.g., project-1 #12) consistent with currentProject.","Verify the issue's project via issue detail before calling ensure branch."],"exampleFix":"// before\nGET ...?currentProject=app&reference=#12   // #12 belongs to 'lib'\n// after\nGET ...?currentProject=lib&reference=#12","handlingStrategy":"validation","validationCode":"if (issue.project.name !== currentProject) {\n  throw new Error(`Issue belongs to ${issue.project.name}, not ${currentProject}`);\n}","typeGuard":"function issueInProject(issue, project) {\n  return issue.project?.name === project;\n}","tryCatchPattern":"try {\n  await ensureBranch(currentProject, ref);\n} catch (e) {\n  if (e.status === 406 || /is not in current project/.test(e.message)) {\n    // re-resolve the issue's project and retry with the correct currentProject\n  } else throw e;\n}","preventionTips":["Derive currentProject from the issue reference (project part) instead of hardcoding.","Resolve full issue references like 'project #12' before calls.","Avoid assuming issue numbers are unique across projects."],"tags":["project-mismatch","validation","issues","onedev"],"backgroundTag":"invalid-argument-value","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"}