{"record":{"id":"d464476ebe0d38a7","repo":"theonedev/onedev","slug":"pull-request-default-assignee-does-not-have-code-w","errorCode":null,"errorMessage":"Pull request default assignee does not have code write permission over the target project: ${userName}","messagePattern":"Pull request default assignee does not have code write permission over the target project: (.+?)","errorType":"exception","errorClass":"ExplicitException","httpStatus":null,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/model/Project.java","lineNumber":2120,"sourceCode":"\t\t\tif (current.getPullRequestSetting().getDeleteSourceBranchAfterMerge() != null)\n\t\t\t\treturn current.getPullRequestSetting().getDeleteSourceBranchAfterMerge();\n\t\t\tcurrent = current.getParent();\n\t\t} while (current != null);\n\n\t\treturn false;\n\t}\n\t\n\tpublic List<User> findDefaultPullRequestAssignees() {\n\t\tProject current = this;\n\t\tdo {\n\t\t\tif (!current.getPullRequestSetting().getDefaultAssignees().isEmpty()) {\n\t\t\t\tvar users = new ArrayList<User>();\n\t\t\t\tfor (var userName: current.getPullRequestSetting().getDefaultAssignees()) {\n\t\t\t\t\tvar user = getUserService().findByName(userName);\n\t\t\t\t\tif (user == null)\n\t\t\t\t\t\tthrow new ExplicitException(\"Pull request default assignee not found: \" + userName);\n\t\t\t\t\telse if (!SecurityUtils.canWriteCode(user.asSubject(), this))\n\t\t\t\t\t\tthrow new ExplicitException(\"Pull request default assignee does not have code write permission over the target project: \" + userName);\n\t\t\t\t\tusers.add(user);\n\t\t\t\t}\n\t\t\t\treturn users;\n\t\t\t}\n\t\t\tcurrent = current.getParent();\n\t\t} while (current != null);\n\n\t\treturn new ArrayList<>();\n\t}\n\t\n\tpublic String getSiteLockName() {\n\t\treturn getSiteLockName(getId());\n\t}\n\t\n\tpublic static String getSiteLockName(Long projectId) {\n\t\treturn \"project-site:\" + projectId;\n\t}\n","sourceCodeStart":2102,"sourceCodeEnd":2138,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/model/Project.java#L2102-L2138","documentation":"After resolving a pull request default assignee by name, OneDev verifies the user actually has code write permission on the target project (SecurityUtils.canWriteCode). This ExplicitException is thrown when the configured default assignee exists but lacks write access, since such a user could not accept/manage the pull request. Like the sibling 'not found' error it is a settings misconfiguration.","triggerScenarios":"Opening a pull request whose target project (or an ancestor providing inherited settings) lists a default assignee that exists but only has read-level access to the target project.","commonSituations":"User role downgraded to read-only after being set as default assignee; assignee belongs to a group without project write access; settings inherited from a parent project where the permission check differs.","solutions":["Grant the default assignee code write permission on the target project (add to a group with Project Write/Code Write role)","Or replace the default assignee in Pull Request settings with a user who already has write permission","Check parent project settings if the project inherits its pull request configuration"],"exampleFix":"// before: assignee 'reader1' has only read access\n// fix in project settings → Pull Request → Default Assignees\ndefaultAssignees: [\"reader1\"]\n// after: use a maintainer\ndefaultAssignees: [\"maintainer1\"]","handlingStrategy":"validation","validationCode":"for (String name : project.getPullRequestSetting().getDefaultAssignees()) {\n    User u = OneDev.getInstance(UserService.class).findByName(name);\n    if (u != null && !SecurityUtils.canWriteCode(u.asSubject(), project))\n        throw new ValidationException(\"Assignee lacks write access: \" + name);\n}","typeGuard":null,"tryCatchPattern":"try {\n    users = project.getPullRequestSetting().getDefaultAssigneeUsers();\n} catch (ExplicitException e) {\n    logger.warn(\"Default assignee lacks write permission: {}\", e.getMessage());\n}","preventionTips":["Verify assignee roles after any permission/role changes","Re-check inherited parent-project settings when permission models change","Document that default assignees must hold code write access"],"tags":["pull-request","permissions","configuration"],"backgroundTag":"permission-denied","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"}