{"record":{"id":"beab12a30a741f01","repo":"theonedev/onedev","slug":"unable-to-find-user-username","errorCode":null,"errorMessage":"Unable to find user '${userName}'","messagePattern":"Unable to find user '(.+?)'","errorType":"exception","errorClass":"ExplicitException","httpStatus":null,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/buildspec/job/action/notificationreceiver/NotificationReceiver.java","lineNumber":67,"sourceCode":"\t\t\tpublic void syntaxError(Recognizer<?, ?> recognizer, Object offendingSymbol, int line,\n\t\t\t\t\tint charPositionInLine, String msg, RecognitionException e) {\n\t\t\t\tthrow new RuntimeException(\"Malformed notification receiver\");\n\t\t\t}\n\t\t\t\n\t\t});\n\t\tCommonTokenStream tokens = new CommonTokenStream(lexer);\n\t\tNotificationReceiverParser parser = new NotificationReceiverParser(tokens);\n\t\tparser.removeErrorListeners();\n\t\tparser.setErrorHandler(new BailErrorStrategy());\n\t\t\n\t\tfor (CriteriaContext criteria: parser.receiver().criteria()) {\n\t\t\tif (criteria.userCriteria() != null) {\n\t\t\t\tString userName = getValue(criteria.userCriteria().Value());\n\t\t\t\tUser user = OneDev.getInstance(UserService.class).findByName(userName);\n\t\t\t\tif (user != null) \n\t\t\t\t\taddEmailAddress(emailAddresses, user);\n\t\t\t\telse \n\t\t\t\t\tthrow new ExplicitException(\"Unable to find user '\" + userName + \"'\");\n\t\t\t} else if (criteria.groupCriteria() != null) {\n\t\t\t\tString groupName = getValue(criteria.groupCriteria().Value());\n\t\t\t\tGroup group = OneDev.getInstance(GroupService.class).find(groupName);\n\t\t\t\tif (group != null) {\n\t\t\t\t\temailAddresses.addAll(group.getMembers().stream()\n\t\t\t\t\t\t\t.map(it->it.getPrimaryEmailAddress())\n\t\t\t\t\t\t\t.filter(it-> it!=null && it.isVerified())\n\t\t\t\t\t\t\t.map(it->it.getValue())\n\t\t\t\t\t\t\t.collect(Collectors.toList()));\n\t\t\t\t} else { \n\t\t\t\t\tthrow new ExplicitException(\"Unable to find group '\" + groupName + \"'\");\n\t\t\t\t}\n\t\t\t} else if (criteria.Committers() != null) {\n\t\t\t\tif (build != null) {\n\t\t\t\t\tfor (RevCommit commit: build.getCommits(null)) {\n\t\t\t\t\t\tPersonIdent committer = commit.getCommitterIdent();\n\t\t\t\t\t\tif (committer != null && StringUtils.isNotBlank(committer.getEmailAddress())) \n\t\t\t\t\t\t\temailAddresses.add(committer.getEmailAddress());","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/buildspec/job/action/notificationreceiver/NotificationReceiver.java#L49-L85","documentation":"Thrown by NotificationReceiver.parse while resolving a notification receiver's user criteria. The user name given in the receiver expression is looked up via UserService.findByName, and if no user matches, an ExplicitException is raised naming the user.","triggerScenarios":"A notification receiver expression like 'to user john' (user criteria) where 'john' is not an existing OneDev user name at parse time.","commonSituations":"User was deleted or renamed after the receiver was configured; typo in the user name; configuring receivers in a template that references users not yet provisioned (e.g. LDAP sync pending).","solutions":["Fix the user name in the notification receiver expression to match an existing OneDev user.","Create the referenced user or wait for the LDAP/user sync that provisions it.","Replace the user criterion with a group or email address criterion if per-user lookup isn't required."],"exampleFix":"// before\nnotification receiver: to user jonh\n\n// after (existing user)\nnotification receiver: to user john","handlingStrategy":"try-catch","validationCode":"User user = OneDev.getInstance(UserService.class).findByName(userName);\nif (user == null)\n    throw new IllegalArgumentException(\"Receiver user '\" + userName + \"' does not exist in OneDev\");","typeGuard":null,"tryCatchPattern":"try {\n    NotificationReceiver.parse(receiverSpec, build, paramMatrix);\n} catch (ExplicitException e) {\n    if (e.getMessage().startsWith(\"Unable to find user\")) {\n        // drop or replace the invalid user criterion\n    } else throw e;\n}","preventionTips":["Verify user names exist before configuring receivers.","Prefer group or email criteria that are less brittle to user renames.","Re-validate receiver configs after user provisioning changes."],"tags":["onedev","notification","user-lookup","buildspec"],"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"}