Application registration for an existing user fails
Application registration for an existing user fails due to the non-nillable user field in the RegistrationRequest struct. Change User type property to a pointer
Thanks for the patch, @TeddyPaddington !
Unfortunately I can't merge it directly, as that domain object is built by inspecting some java objects. We'll have to find some way to upstream the change.
I'm no go expert; can you please show me how this change affects making a go client call? That's been one reason I haven't tried to fix this, I'm not sure how to test whether it'd be a breaking change or not.
Ran into the same problem. The reason for the bug is that the User object is embedded into the RegistrationRequest and the json encoder cannot determine that it is empty, so it serializes it with empty fields into the request and it's then rejected by the server.
Two other solutions are to create a separate RegistrationWithExistingUserRequest (presumably in the java source) or to change the server so it ignores the User object if it only has empty fields.
Just ran into this issue today.
as that domain object is built by inspecting some java objects.
@mooreds you're saying the Go code is generated from Java objects? To your earlier question, Go struct fields don't have a nil value possible by default. The default/zero value is an empty struct, so if I say
//create new request
req := fusionAuth.RegistrationRequest{}
it's equivalent to saying
//create new request
req := fusionAuth.RegistrationRequest{
User: fusionAuth.User{}
}
When that gets marshaled to JSON, it looks like:
{
"user": {}
}
Which, because not null, is getting validated for fields. Making this PR change allows the User field to have a nil value which is marshaled as { "user": null } and allows the client call to succeed.
I wrote a custom function in my local app to use a copied request struct (with this change) that mirrors the existing Register() function and it works like a champ.
Merge it
Thanks @smilad . We need to take a look at this, but unfortunately are busy with some other things internally (new release, documentation overhaul). Hopefully we can get to this in the next month or two. Sorry for the delay!
Hi guys, any update on this? We're facing the same issue