xwikisas/application-ldapuserimport

Null key for a Map not allowed in JSON

Opened this issue · 0 comments

There is a particular case, when the uid field is part of the fields mapping, that causes

Failed to serialize object to JSON 
com.fasterxml.jackson.databind.JsonMappingException: Null key for a Map not allowed in JSON (use a converting
NullKeySerializer?) (through reference chain: java.util.LinkedHashMap["users"]->java.util.HashMap["null"])

on https://github.com/xwikisas/application-ldapuserimport/blob/main/application-ldapuserimport-api/src/main/java/com/xwiki/ldapuserimport/internal/DefaultLDAPUserImportManager.java#L289.
For example, if the uid is sn and the mapping contains last_name=sn.
This can happen when the uid is sn because there is a default mapping (first_name=givenName,last_name=sn,email=mail) that improves the usability of the application (it can work without configuring the mapping on UI) and it can also happen when the administrator explicitly configures the mapping to contain it.

What is needed here is a better way of building the users Map.