{"record":{"id":"677220d56b0fdc6f","repo":"theonedev/onedev","slug":"unable-to-find-user-username-677220","errorCode":null,"errorMessage":"Unable to find user '${userName}'","messagePattern":"Unable to find user '(.+?)'","errorType":"validation","errorClass":"ExplicitException","httpStatus":null,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/util/reviewrequirement/ReviewRequirement.java","lineNumber":64,"sourceCode":"\t\t\t});\n\t\t\tCommonTokenStream tokens = new CommonTokenStream(lexer);\n\t\t\tReviewRequirementParser parser = new ReviewRequirementParser(tokens);\n\t\t\tparser.removeErrorListeners();\n\t\t\tparser.setErrorHandler(new BailErrorStrategy());\n\t\t\t\n\t\t\tRequirementContext requirementContext = parser.requirement();\n\t\t\t\n\t\t\tfor (CriteriaContext criteria: requirementContext.criteria()) {\n\t\t\t\tif (criteria.userCriteria() != null) {\n\t\t\t\t\tString userName = getValue(criteria.userCriteria().Value());\n\t\t\t\t\tUser user = OneDev.getInstance(UserService.class).findByName(userName);\n\t\t\t\t\tif (user != null) {\n\t\t\t\t\t\tif (!users.contains(user)) \n\t\t\t\t\t\t\tusers.add(user);\n\t\t\t\t\t\telse \n\t\t\t\t\t\t\tthrow new ExplicitException(\"User '\" + userName + \"' is included multiple times\");\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow new ExplicitException(\"Unable to find user '\" + userName + \"'\");\n\t\t\t\t\t}\n\t\t\t\t} else if (criteria.groupCriteria() != null) {\n\t\t\t\t\tString groupName = getValue(criteria.groupCriteria().Value());\n\t\t\t\t\tGroup group = OneDev.getInstance(GroupService.class).find(groupName);\n\t\t\t\t\tif (group != null) {\n\t\t\t\t\t\tif (!groups.containsKey(group)) {\n\t\t\t\t\t\t\tTerminalNode digit = criteria.groupCriteria().DIGIT();\n\t\t\t\t\t\t\tif (digit != null) \n\t\t\t\t\t\t\t\tgroups.put(group, Integer.parseInt(digit.getText()));\n\t\t\t\t\t\t\telse \n\t\t\t\t\t\t\t\tgroups.put(group, 1);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthrow new ExplicitException(\"Group '\" + groupName + \"' is included multiple times\");\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow new ExplicitException(\"Unable to find group '\" + groupName + \"'\");\n\t\t\t\t\t}\n\t\t\t\t}","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/util/reviewrequirement/ReviewRequirement.java#L46-L82","documentation":"During review requirement parsing, a 'user:<name>' criterion whose name cannot be resolved by UserService.findByName throws ExplicitException. The requirement cannot be evaluated if a referenced user does not exist.","triggerScenarios":"Parsing a requirement referencing a user login that does not exist (renamed, deleted, or typo), e.g. 'user:bobb'.","commonSituations":"User deleted or renamed after the requirement was configured; copied config from another OneDev instance; case/whitespace mismatch in the login name.","solutions":["Correct the user login in the requirement string to an existing user","Recreate the referenced user or update the requirement to a group instead","Catch ExplicitException during config save to validate the requirement before persisting"],"exampleFix":"// before\nreviewRequirement = \"user:bobb\";\n// after\nreviewRequirement = \"user:bob\";","handlingStrategy":"validation","validationCode":"UserService userService = OneDev.getInstance(UserService.class);\nfor (String name : extractUserNames(requirement)) {\n    if (userService.findByName(name) == null)\n        throw new ExplicitException(\"Unknown user in requirement: \" + name);\n}","typeGuard":null,"tryCatchPattern":"try {\n    ReviewRequirement.parse(req);\n} catch (ExplicitException e) {\n    ui.showError(e.getMessage());\n}","preventionTips":["Pick users via a user picker that only offers existing accounts","Re-validate requirements when users are deleted or renamed","Use group criteria to reduce dependence on individual logins"],"tags":["review-requirement","user-not-found","validation"],"backgroundTag":"user-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"}