{"record":{"id":"d9e37383a1a20bc9","repo":"theonedev/onedev","slug":"user-not-found-username","errorCode":null,"errorMessage":"User not found: ${userName}","messagePattern":"User not found: (.+?)","errorType":"http","errorClass":"NotFoundException","httpStatus":404,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/ai/TodResource.java","lineNumber":407,"sourceCode":"                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    }\n \n    @Path(\"/query-issues\")\n    @GET\n    public List<Map<String, Object>> queryIssues(","sourceCodeStart":389,"sourceCodeEnd":425,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/ai/TodResource.java#L389-L425","documentation":"After trying lookup by name, by full name, and by email match, the endpoint throws NotFoundException(\"User not found: <userName>\") when no user matches the supplied userName. The authenticated caller is valid, but the requested account does not exist.","triggerScenarios":"GET /get-login-name?userName=<value> where the value matches no login name, no full name, and no user email (findByName and findByFullName return null and no matching users accumulate).","commonSituations":"Typo in user name; user deleted or deactivated; passing email when lookup expects name/full name on a version without email matching; case/whitespace mismatch; AI agent hallucinating a user name from chat context.","solutions":["Verify the exact login name on the Users administration page and pass it exactly.","Trim whitespace and check case/URL-encoding of the userName parameter.","Confirm the user still exists and is active (not deleted/renamed).","If userName is optional for your use case, omit it to get the current user's login name.","Catch the 404 in the client and prompt the user to pick a valid account."],"exampleFix":"// before\nGET /~ai/get-login-name?userName=Jon%20Doe    // typo\n// after\nGET /~ai/get-login-name?userName=John%20Doe   // existing user","handlingStrategy":"validation","validationCode":"const known = await api.listUsers(); if (!known.includes(userName)) throw new Error('unknown user: ' + userName);","typeGuard":null,"tryCatchPattern":"try { return await api.getLoginName(userName); } catch (e) { if (/User not found/i.test(e.message)) { suggestValidUsers(userName); return null; } throw e; }","preventionTips":["Copy login names from the Users page instead of typing them","Trim and URL-encode the userName parameter","Confirm the user exists and is active","Omit userName to resolve the current user"],"tags":["users","rest","not-found","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"}