Error updating guest user

Hi,

I am encountering the following issue :

  • Create a guest user → the user in database gets a “fake” identity value in the email column that looks like “sZdg6Ljs7a”

  • Try to update the user in order to add a property, like so :

  • This call returns a 400 error, which says : Error: Provided email has wrong format.

The issue is that the email hasn’t changed. In fact it hasn’t really been set yet.

In my opinion, if the email isn’t changing, then this should not return an error, it should only modify the changed values.

Could you advise if this is the expected behavior, and if so, what kind of workaround you advise in order to update a guest user ?

Thanks.

hello @Nicolas_REMY

unfortunately, updating guest users does not work from cloud code in the way you would like to, but there is a workaround:

You create a guest user, then create a new object with objectId that you have extracted from the guest user

Hi @sergey.kuk and thank you for the reply.

Just to help me be sure that I 100% understand, could you cross-check the following ?

What you are telling me is that if I update the user with the built-in method, it will be sending the email back to the database, which will try to overwrite it and create an error. The workaround that you are describing is just creating an object with the changes to the user instead of sending back all the properties, and the server will only try to update those changes, and leave the other fields untouched. Am I correct ?

If my understanding is correct, then this should indeed work fine, that’s great. However, for the ease of use, and in order to avoid such pitfalls, shouldn’t the built-in “Update User” method deal with this situation for guest users ?

The workaround that you are describing is just creating an object with the changes to the user instead of sending back all the properties, and the server will only try to update those changes, and leave the other fields untouched. Am I correct ?

Yes, the server will update only fields that you send.

shouldn’t the built-in “Update User” method deal with this situation for guest users?

yes it should, and I have already created an internal ticket BKNDLSS-28835 to fix the issue

1 Like

Excellent, thanks.