{"record":{"id":"42e4bc1b335f135b","repo":"SonarSource/sonarqube","slug":"user-s-doesn-t-exist-42e4bc","errorCode":null,"errorMessage":"User '%s' doesn't exist","messagePattern":"User '(.+?)' doesn't exist","errorType":"exception","errorClass":"NotFoundException","httpStatus":404,"severity":"error","filePath":"server/sonar-webserver-webapi/src/main/java/org/sonar/server/user/ws/UpdateLoginAction.java","lineNumber":98,"sourceCode":"\n  @Override\n  public void handle(Request request, Response response) throws Exception {\n    userSession.checkLoggedIn().checkIsSystemAdministrator();\n    managedInstanceChecker.throwIfInstanceIsManaged();\n    String login = request.mandatoryParam(PARAM_LOGIN);\n    String newLogin = request.mandatoryParam(PARAM_NEW_LOGIN);\n    try (DbSession dbSession = dbClient.openSession(false)) {\n      UserDto user = getUser(dbSession, login);\n      userUpdater.updateAndCommit(dbSession, user, new UpdateUser().setLogin(newLogin), u -> {\n      });\n      response.noContent();\n    }\n  }\n\n  private UserDto getUser(DbSession dbSession, String login) {\n    UserDto user = dbClient.userDao().selectByLogin(dbSession, login);\n    if (user == null || !user.isActive()) {\n      throw new NotFoundException(format(\"User '%s' doesn't exist\", login));\n    }\n    return user;\n  }\n\n}\n","sourceCodeStart":80,"sourceCodeEnd":104,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/server/sonar-webserver-webapi/src/main/java/org/sonar/server/user/ws/UpdateLoginAction.java#L80-L104","documentation":"UpdateLoginAction (api/users/update_login) throws this NotFoundException when the current login does not identify an existing active user. Renaming a login requires resolving the old login first; deactivated or missing users are rejected identically. The new login must additionally be free of reserved characters.","triggerScenarios":"POST api/users/update_login with login=<old login> that matches no user row or an inactive user.","commonSituations":"Corporate rename scripts using stale HR exports; user deactivated after leave but still in the rename list; using email address as login; case or whitespace differences between directory and SonarQube login.","solutions":["Look up the exact login with GET api/users/search before renaming; use the returned 'login' field verbatim.","Reactivate the user via api/users/update (active=true) if it was disabled, then perform the rename.","Skip/create the user as appropriate: POST api/users/create for missing accounts.","Refresh the source-of-truth export so it reflects current SonarQube users instead of stale data."],"exampleFix":"// before: renaming from a stale HR list\ncurl -su \"$ADMIN:\" -X POST 'https://sonar/api/users/update_login?login=j.smith&newLogin=jane.smith'\n// after: verify login exists first\nLOGIN=$(curl -su \"$ADMIN:\" 'https://sonar/api/users/search?q=j.smith' | jq -r '.users[0].login')\n[ -n \"$LOGIN\" ] && curl -su \"$ADMIN:\" -X POST \"https://sonar/api/users/update_login?login=$LOGIN&newLogin=jane.smith\"","handlingStrategy":"validation","validationCode":"const {users} = await fetch(`${base}/api/users/search?q=${encodeURIComponent(login)}`, {headers: auth}).then(r => r.json());\nconst user = users.find(u => u.login === login && u.active);\nif (!user) throw new Error(`cannot rename ${login}: missing or inactive`);\nif (!/^[^';\"\\\\\\\\]+$/.test(newLogin)) throw new Error(`newLogin ${newLogin} contains reserved characters`);","typeGuard":"function isRenamableUser(u, login) {\n  return u != null && u.login === login && u.active === true;\n}","tryCatchPattern":"try {\n  await updateLogin(login, newLogin);\n} catch (e) {\n  if (e.status === 404 && /doesn't exist/.test(e.message)) {\n    skipped.push(login); // not present or deactivated\n    return;\n  }\n  throw e;\n}","preventionTips":["Validate logins against api/users/search before batch renames","Skip deactivated users or reactivate them first","Use exact login strings from the API, not HR/export names","Refresh rename lists immediately before execution"],"tags":["sonarqube","rest-api","user-management","not-found"],"backgroundTag":"user-not-found","analyzedSha":"184c821202192afc1c599fc912d0889b69fffa53","analyzedAt":"2026-09-09T12:23:51.573Z","contentChangedAt":"2026-09-09T12:23:51.573Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}