{"record":{"id":"4b9f9294ce765030","repo":"apache/druid","slug":"user-s-does-not-exist","errorCode":null,"errorMessage":"User [%s] does not exist.","messagePattern":"User \\[(.+?)\\] does not exist\\.","errorType":"http","errorClass":"BasicSecurityDBResourceException","httpStatus":400,"severity":"warning","filePath":"extensions-core/druid-basic-security/src/main/java/org/apache/druid/security/basic/authentication/db/updater/CoordinatorBasicAuthenticatorMetadataStorageUpdater.java","lineNumber":392,"sourceCode":"    );\n    if (userMap.get(userName) != null) {\n      throw new BasicSecurityDBResourceException(\"User [%s] already exists.\", userName);\n    } else {\n      userMap.put(userName, new BasicAuthenticatorUser(userName, null));\n    }\n    byte[] newValue = BasicAuthUtils.serializeAuthenticatorUserMap(objectMapper, userMap);\n    return tryUpdateUserMap(prefix, userMap, oldValue, newValue);\n  }\n\n  private boolean deleteUserOnce(String prefix, String userName)\n  {\n    byte[] oldValue = getCurrentUserMapBytes(prefix);\n    Map<String, BasicAuthenticatorUser> userMap = BasicAuthUtils.deserializeAuthenticatorUserMap(\n        objectMapper,\n        oldValue\n    );\n    if (userMap.get(userName) == null) {\n      throw new BasicSecurityDBResourceException(\"User [%s] does not exist.\", userName);\n    } else {\n      userMap.remove(userName);\n    }\n    byte[] newValue = BasicAuthUtils.serializeAuthenticatorUserMap(objectMapper, userMap);\n    return tryUpdateUserMap(prefix, userMap, oldValue, newValue);\n  }\n\n  private boolean setUserCredentialOnce(String prefix, String userName, BasicAuthenticatorCredentials credentials)\n  {\n    byte[] oldValue = getCurrentUserMapBytes(prefix);\n    Map<String, BasicAuthenticatorUser> userMap = BasicAuthUtils.deserializeAuthenticatorUserMap(\n        objectMapper,\n        oldValue\n    );\n    if (userMap.get(userName) == null) {\n      throw new BasicSecurityDBResourceException(\"User [%s] does not exist.\", userName);\n    } else {\n      userMap.put(userName, new BasicAuthenticatorUser(userName, credentials));","sourceCodeStart":374,"sourceCodeEnd":410,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/extensions-core/druid-basic-security/src/main/java/org/apache/druid/security/basic/authentication/db/updater/CoordinatorBasicAuthenticatorMetadataStorageUpdater.java#L374-L410","documentation":"Thrown as BasicSecurityDBResourceException when deleteUserOnce does not find the named user in the authenticator user map. Deleting a non-existent user is rejected rather than silently ignored. Surfaced to the HTTP caller as an error response.","triggerScenarios":"Calling deleteUser (DELETE /druid-ext/basic-security/authentication/<authenticator>/users/<userName>) for a userName that is not in the stored user map.","commonSituations":"Cleanup scripts deleting users that were already removed or never created; typo in the userName; deleting users on the wrong authenticator name (e.g. 'druid-ha' vs 'basic'); retries after a successful first delete.","solutions":["Verify the user exists via GET before calling DELETE","Confirm the correct authenticator name is being targeted","Make deletion idempotent in scripts: ignore 404/BasicSecurityDBResourceException responses","Correct the userName spelling/configuration"],"exampleFix":"// before\nclient.deleteUser(authenticatorName, userName); // fails if missing\n// after\nResponse res = client.deleteUser(authenticatorName, userName);\nif (res.getStatus() != 200 && !\"User ... does not exist\".contains(userName)) {\n  throw new RuntimeException(\"delete failed\");\n}","handlingStrategy":"validation","validationCode":"Response r = client.getUser(authenticatorName, userName);\nif (r.getStatus() != 200) { /* nothing to delete */ return; }","typeGuard":null,"tryCatchPattern":"try {\n  client.deleteUser(authenticatorName, userName);\n} catch (WebApplicationException e) {\n  if (isDoesNotExistResponse(e)) { /* idempotent: already gone */ } else throw e;\n}","preventionTips":["Confirm the exact userName and authenticator name before deleting","Treat 'does not exist' deletions as success in cleanup scripts","Check for concurrent deletions by other admins/tools"],"tags":["resource-not-found","basic-security","user-management"],"backgroundTag":"user-not-found","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}