{"record":{"id":"9049fa35a68dbba8","repo":"apache/druid","slug":"couldn-t-serialize-authenticator-usermap","errorCode":null,"errorMessage":"Couldn't serialize authenticator userMap!","messagePattern":"Couldn't serialize authenticator userMap!","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"extensions-core/druid-basic-security/src/main/java/org/apache/druid/security/basic/BasicAuthUtils.java","lineNumber":149,"sourceCode":"        userMap = objectMapper.readValue(userMapBytes, AUTHENTICATOR_USER_MAP_TYPE_REFERENCE);\n      }\n      catch (IOException ioe) {\n        throw new RuntimeException(\"Couldn't deserialize authenticator userMap!\", ioe);\n      }\n    }\n    return userMap;\n  }\n\n  public static byte[] serializeAuthenticatorUserMap(\n      ObjectMapper objectMapper,\n      Map<String, BasicAuthenticatorUser> userMap\n  )\n  {\n    try {\n      return objectMapper.writeValueAsBytes(userMap);\n    }\n    catch (IOException ioe) {\n      throw new ISE(ioe, \"Couldn't serialize authenticator userMap!\");\n    }\n  }\n\n  public static Map<String, BasicAuthorizerUser> deserializeAuthorizerUserMap(\n      ObjectMapper objectMapper,\n      byte[] userMapBytes\n  )\n  {\n    Map<String, BasicAuthorizerUser> userMap;\n    if (userMapBytes == null) {\n      userMap = new HashMap<>();\n    } else {\n      try {\n        userMap = objectMapper.readValue(userMapBytes, BasicAuthUtils.AUTHORIZER_USER_MAP_TYPE_REFERENCE);\n      }\n      catch (IOException ioe) {\n        throw new RuntimeException(\"Couldn't deserialize authorizer userMap!\", ioe);\n      }","sourceCodeStart":131,"sourceCodeEnd":167,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/extensions-core/druid-basic-security/src/main/java/org/apache/druid/security/basic/BasicAuthUtils.java#L131-L167","documentation":"BasicAuthUtils.serializeAuthenticatorUserMap writes the authenticator user map to JSON bytes with Jackson. If writeValueAsBytes throws (IOException family), it throws ISE('Couldn't serialize authenticator userMap!'). This is rare since BasicAuthenticatorUser is a simple POJO, but failures indicate a mapper/serialization incompatibility.","triggerScenarios":"Saving the authenticator user map when the ObjectMapper lacks a serializer for a contained type or the user map contains a non-serializable object (e.g. wrong generic map passed in).","commonSituations":"Passing a Map<String, BasicAuthorizerUser> (wrong type) to the authenticator serializer, custom Jackson modules missing, or mixing authorizer/authenticator maps in custom code.","solutions":["Ensure the map passed is Map<String, BasicAuthenticatorUser> and built from BasicAuthUtils.deserializeAuthenticatorUserMap","Verify the Jackson ObjectMapper is the Druid-standard mapper (no conflicting modules)","Catch and log the ISE at call sites to identify which map content failed"],"exampleFix":"// before\nMap<String, BasicAuthorizerUser> m = ...;\nbyte[] b = BasicAuthUtils.serializeAuthenticatorUserMap(mapper, m);\n// after\nMap<String, BasicAuthenticatorUser> m = BasicAuthUtils.deserializeAuthenticatorUserMap(mapper, bytes);\nbyte[] b = BasicAuthUtils.serializeAuthenticatorUserMap(mapper, m);","handlingStrategy":"try-catch","validationCode":"// Ensure the map contains only expected value types\nboolean valid = userMap.values().stream().allMatch(v -> v instanceof BasicAuthenticatorUser);","typeGuard":"boolean isAuthenticatorUserMap(Map<String, ?> m) {\n  return m.values().stream().allMatch(BasicAuthenticatorUser.class::isInstance);\n}","tryCatchPattern":"try {\n  byte[] b = BasicAuthUtils.serializeAuthenticatorUserMap(mapper, userMap);\n} catch (ISE e) {\n  if (e.getMessage().contains(\"Couldn't serialize authenticator userMap!\")) {\n    // rebuild map from deserialization and retry\n  } else throw e;\n}","preventionTips":["Only round-trip maps obtained from the matching deserialize method","Use the standard Druid ObjectMapper","Add integration tests that serialize/deserialize the user map"],"tags":["java","security","jackson","serialization"],"backgroundTag":"json-marshal-failed","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}