Repository: lldap/lldap (language: rust)

Issue:
[BUG] Cannot update display name of a user
**Describe the bug**
When I save user information, more precisely modified 'Display name' (in edit mode not create a new one), I receive an error in the user panel management:
```
Errors: [updateUser:2:3: Internal error: `User attribute name display_name doesn't exist in the schema, yet was attempted to be removed from the database`]
```

**To Reproduce**
1. Go to user list
2. Click on login
3. Change 'Display name' value
4. Click 'Save changes'

**Expected behavior**
'Display name' will be saved correct.

**Logs**
```
ERROR    │     ┕━ 🚨 [error]:  | error: Internal error: `User attribute name display_name doesn't exist in the schema, yet was attempted to be removed from the database`
```

**Additional context**
However `display_name` exists in the schema and in the database.

Environment: LLDAP dockered version: lldap/lldap:2024-10-24-debian + MySQL backend



Discussion / hints:

Fix patch:
diff --git a/server/src/infra/graphql/mutation.rs b/server/src/infra/graphql/mutation.rs
index 2c2312d9..e492585f 100644
--- a/server/src/infra/graphql/mutation.rs
+++ b/server/src/infra/graphql/mutation.rs
@@ -265,6 +265,14 @@ impl<Handler: BackendHandler> Mutation<Handler> {
             display_name,
             attributes: insert_attributes,
         } = unpack_attributes(user_insert_attributes, &schema, is_admin)?;
+        let display_name = display_name.or_else(|| {
+            // If the display name is not inserted, but removed, reset it.
+            user.remove_attributes
+                .iter()
+                .flatten()
+                .find(|attr| *attr == "display_name")
+                .map(|_| String::new())
+        });
         handler
             .update_user(UpdateUserRequest {
                 user_id,
@@ -277,7 +285,7 @@ impl<Handler: BackendHandler> Mutation<Handler> {
                     .remove_attributes
                     .unwrap_or_default()
                     .into_iter()
-                    .filter(|attr| attr != "mail") // mail can be sent when editing an admin user
+                    .filter(|attr| attr != "mail" && attr != "display_name")
                     .map(Into::into)
                     .collect(),
                 insert_attributes,


Test patch: