{"record":{"id":"5e0a99fba2bbc6e5","repo":"SonarSource/sonarqube","slug":"user-s-doesn-t-exist","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/UpdateAction.java","lineNumber":148,"sourceCode":"\n  private void doHandle(DbSession dbSession, UpdateRequest request, UserDto userDto) {\n    UpdateUser updateUser = new UpdateUser();\n    if (request.getName() != null) {\n      updateUser.setName(request.getName());\n    }\n    if (request.getEmail() != null) {\n      updateUser.setEmail(emptyToNull(request.getEmail()));\n    }\n    if (!request.getScmAccounts().isEmpty()) {\n      updateUser.setScmAccounts(request.getScmAccounts());\n    }\n    userUpdater.updateAndCommit(dbSession, userDto, updateUser, u -> {});\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  private void writeUser(DbSession dbSession, Response response, String uuid) {\n    try (JsonWriter json = response.newJsonWriter()) {\n      json.beginObject();\n      json.name(\"user\");\n      UserDto user = dbClient.userDao().selectByUuid(dbSession, uuid);\n      checkState(user != null, \"User with uuid '%s' doesn't exist\", uuid);\n      Set<String> groups = new HashSet<>(dbClient.groupMembershipDao().selectGroupsByLogins(dbSession, singletonList(uuid)).get(uuid));\n      userWriter.write(json, user, groups, UserJsonWriter.FIELDS);\n      json.endObject().close();\n    }\n  }\n\n  private static UpdateRequest toWsRequest(Request request) {\n    List<String> scmAccounts = parseScmAccounts(request);","sourceCodeStart":130,"sourceCodeEnd":166,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/server/sonar-webserver-webapi/src/main/java/org/sonar/server/user/ws/UpdateAction.java#L130-L166","documentation":"The user update web service (api/users/update) throws this NotFoundException when the target login does not match an existing active user. Like other user WS actions, a deactivated user is indistinguishable from a missing one, so disabled accounts also produce this error. It prevents silently updating a non-existent account.","triggerScenarios":"POST api/users/update with login=<login> where selectByLogin returns null or the user has active=false.","commonSituations":"Typo in login; user deactivated before the update script ran; updating via email or display name instead of login; user deleted between listing and updating (race); provisioning delays for SSO users.","solutions":["Confirm the exact login via GET api/users/search?q=<term> as an administrator and use that login value.","Reactivate deactivated users with POST api/users/update (active=true) or via Administration > Users before applying other changes.","Create the user if it does not exist (POST api/users/create) before updating.","Fix automation scripts to look up logins dynamically rather than hardcoding stale values."],"exampleFix":"// before: hardcoded possibly-deactivated login\ncurl -u \"$ADMIN:\" -X POST 'https://sonar/api/users/update?login=bob&name=Robert'\n// after: verify first, then update\nLOGIN=$(curl -su \"$ADMIN:\" 'https://sonar/api/users/search?q=bob' | jq -r '.users[0].login')\ncurl -u \"$ADMIN:\" -X POST \"https://sonar/api/users/update?login=$LOGIN&name=Robert\"","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 update: ${login} missing or inactive`);","typeGuard":"function isUpdatableUser(u, login) {\n  return u != null && u.login === login && u.active === true;\n}","tryCatchPattern":"try {\n  await updateUser(login, changes);\n} catch (e) {\n  if (e.status === 404 && /doesn't exist/.test(e.message)) {\n    // refresh login list / reactivate user, then retry once\n  } else throw e;\n}","preventionTips":["Always look up logins dynamically before updates","Exclude inactive users from update batches","Never substitute email or display name for login","Re-sync automation source data with current server users"],"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"}