{"record":{"id":"d39e5644fe920ccf","repo":"theonedev/onedev","slug":"multiple-users-found-username","errorCode":null,"errorMessage":"Multiple users found: ${userName}","messagePattern":"Multiple users found: (.+?)","errorType":"http","errorClass":"NotAcceptableException","httpStatus":406,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/ai/TodResource.java","lineNumber":403,"sourceCode":"        User user;                \n        if (userName != null) {\n            user = userService.findByName(userName);\n            if (user == null)\n                user = userService.findByFullName(userName);\n            if (user == null) {\n                var matchingUsers = new ArrayList<User>();\n                var lowerCaseUserName = userName.toLowerCase();\n                for (var eachUser: userService.query()) {\n                    if (eachUser.getFullName() != null) {\n                        if (Splitter.on(\" \").trimResults().omitEmptyStrings().splitToList(eachUser.getFullName().toLowerCase()).contains(lowerCaseUserName)) {\n                            matchingUsers.add(eachUser);\n                        }\n                    }\n                }\n                if (matchingUsers.size() == 1) {\n                    user = matchingUsers.get(0);\n                } else if (matchingUsers.size() > 1) {\n                    throw new NotAcceptableException(\"Multiple users found: \" + userName);\n                }\n            }\n            if (user == null) \n                throw new NotFoundException(\"User not found: \" + userName);\n        } else {\n            user = SecurityUtils.getUser();\n        }\n        return user.getName();\n    }\n\n    @Path(\"/get-unix-timestamp\")\n    @GET\n    public long getUnixTimestamp(@QueryParam(\"dateTimeDescription\") @NotNull String dateTimeDescription) {\n        if (SecurityUtils.getUser() == null)\n            throw new UnauthenticatedException();\n\n        return DateUtils.parseRelaxed(dateTimeDescription).getTime();\n    }","sourceCodeStart":385,"sourceCodeEnd":421,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/ai/TodResource.java#L385-L421","documentation":"When userName matches multiple accounts (e.g. a full name shared by several users), the endpoint cannot disambiguate and throws NotAcceptableException(\"Multiple users found: <userName>\"). This happens only after authentication succeeds and the primary lookups (by name, then full name) fell through to ambiguous full-name matching.","triggerScenarios":"GET /get-login-name?userName=<fullName> where the name is not a unique login name, and several users share that full name, producing matchingUsers.size() > 1.","commonSituations":"Passing a display name like \"John Smith\" when two John Smiths exist; passing a non-login name that the service resolves via findByFullName; AI agents guessing user identifiers from conversation text.","solutions":["Pass the exact unique login name instead of a full name.","List users (via admin user query) to find the unique login name and use that.","Include more disambiguating information and pick the correct account before calling.","If you administer OneDev, rename duplicate full names so full-name lookup is unambiguous."],"exampleFix":"// before\nGET /~ai/get-login-name?userName=John%20Smith   // ambiguous\n// after\nGET /~ai/get-login-name?userName=john.smith2    // unique login name","handlingStrategy":"validation","validationCode":"// resolve uniqueness before calling: use admin user search\nconst matches = await adminApi.searchUsers(userName); if (matches.length !== 1) throw new Error('userName is ambiguous: ' + userName);","typeGuard":null,"tryCatchPattern":"try { return await api.getLoginName(userName); } catch (e) { if (/Multiple users found/i.test(e.message)) { const pick = await promptUserToDisambiguate(userName); return api.getLoginName(pick); } throw e; }","preventionTips":["Always pass unique login names, never display names","Keep full names unique in the OneDev user directory","Surface ambiguity to the end user instead of guessing"],"tags":["users","ambiguity","rest","lookup"],"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"}