theonedev/onedev · error · NotFoundException

User not found: ${userName}

Error message

User not found: ${userName}

What it means

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.

Source

Thrown at server-core/src/main/java/io/onedev/server/ai/TodResource.java:407

                user = userService.findByFullName(userName);
            if (user == null) {
                var matchingUsers = new ArrayList<User>();
                var lowerCaseUserName = userName.toLowerCase();
                for (var eachUser: userService.query()) {
                    if (eachUser.getFullName() != null) {
                        if (Splitter.on(" ").trimResults().omitEmptyStrings().splitToList(eachUser.getFullName().toLowerCase()).contains(lowerCaseUserName)) {
                            matchingUsers.add(eachUser);
                        }
                    }
                }
                if (matchingUsers.size() == 1) {
                    user = matchingUsers.get(0);
                } else if (matchingUsers.size() > 1) {
                    throw new NotAcceptableException("Multiple users found: " + userName);
                }
            }
            if (user == null) 
                throw new NotFoundException("User not found: " + userName);
        } else {
            user = SecurityUtils.getUser();
        }
        return user.getName();
    }

    @Path("/get-unix-timestamp")
    @GET
    public long getUnixTimestamp(@QueryParam("dateTimeDescription") @NotNull String dateTimeDescription) {
        if (SecurityUtils.getUser() == null)
            throw new UnauthenticatedException();

        return DateUtils.parseRelaxed(dateTimeDescription).getTime();
    }
 
    @Path("/query-issues")
    @GET
    public List<Map<String, Object>> queryIssues(

View on GitHub (pinned to d44925c47c)

Solutions

  1. Verify the exact login name on the Users administration page and pass it exactly.
  2. Trim whitespace and check case/URL-encoding of the userName parameter.
  3. Confirm the user still exists and is active (not deleted/renamed).
  4. If userName is optional for your use case, omit it to get the current user's login name.
  5. Catch the 404 in the client and prompt the user to pick a valid account.

Example fix

// before
GET /~ai/get-login-name?userName=Jon%20Doe    // typo
// after
GET /~ai/get-login-name?userName=John%20Doe   // existing user
Defensive patterns

Strategy: validation

Validate before calling

const known = await api.listUsers(); if (!known.includes(userName)) throw new Error('unknown user: ' + userName);

Try / catch

try { return await api.getLoginName(userName); } catch (e) { if (/User not found/i.test(e.message)) { suggestValidUsers(userName); return null; } throw e; }

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Understand the failure class

Background: "User not found", "Invalid user", and "does not exist": what missing-user lookup errors mean across Rocket.Chat, LiteLLM, Phabricator, rustfs, and pnpm — this error's family across 10 libraries.

Related errors


AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06). Data as JSON: /api/errors/d9e37383a1a20bc9. Report an issue: GitHub.