Clearing custom client attributes

Hi,

I’m programmatically adding custom attributes to clients via the API in order to use them to adjust the login pages via the templates.
I have noticed that once I added an attribute I cannot remove it again. The request to org.keycloak.services.resources.admin.ClientResource#update simply ignores attributes that are not present.

So I thought the next-best thing I can do is set them to empty strings. This means that my test for the presence of an attribute in the templates has to check for emptry strings as well now. It’s something like <#if (client.attributes["my-custom-attribute"])?? && client.attributes["my-custom-attribute"] != "">

In looking at how the Keycloak code handles this I stumbled upon some code that I think is wrong. In https://github.com/keycloak/keycloak/blame/master/server-spi-private/src/main/java/org/keycloak/models/utils/RepresentationToModel.java#L1503 the attributes are handled twice. Looking at the commits on those lines I get the impression that this was a merge error. First the code handling the attributes was duplicated. Then in another commitremoveEmptyString was added to the duplicated code without adjusting the code above. This is lucky for me because otherwise I wouldn’t even be able to set the value of an attribute to the empty string!

Does anyone know what the intention here is and if there’s maybe a better way to get rid of custom attributes again or how to deal with empty values better in templates?

Thanks,
Simon