When synchronizing or retrieving users from LDAP, Ametys throws an exception if the givenName (first name) attribute exists in LDAP but has no value.
Instead of handling the empty attribute gracefully, the application crashes with a NoSuchElementException.
This situation can occur when the attribute is present in the LDAP but empty for some users.
Steps to Reproduce:
- Create or modify a user entry in LDAP.
- Set an attribute (for example the one used by the User Directory as the first name) so that it exists but contains an empty value.
- List users in cms or admin workspace
Expected Behavior:
Ametys should ignore the empty attribute and retrieve the other users
Actual Behavior:
Ametys throws an exception and fails to retrieve users.
Error Stack Trace:
Caused by: java.util.NoSuchElementException: Attribute givenName has no value at java.naming/javax.naming.directory.BasicAttribute#get:299 at org.ametys.plugins.core.impl.user.directory.LdapUserDirectory#_getAttributes:947 at org.ametys.plugins.core.impl.user.directory.LdapUserDirectory#_users:748 at org.ametys.plugins.core.impl.user.directory.LdapUserDirectory#_internalGetUsers:688 at org.ametys.plugins.core.impl.user.directory.LdapUserDirectory#getStoredUsers:318 at org.ametys.core.user.UserManager#getUsers:317 at org.ametys.core.user.UserManager#getUsers:268 at org.ametys.plugins.core.user.UserDAO#searchUsersByPopulation:248 at java.base/jdk.internal.reflect.DirectMethodHandleAccessor#invoke:103 ... 91 more