Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Application registration for an existing user fails #61

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

TeddyPaddington
Copy link

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

…llable user field in the RegistrationRequest struct
@mooreds
Copy link
Contributor

mooreds commented Feb 9, 2022

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.

@ziemek
Copy link

ziemek commented Jun 23, 2022

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.

@mshap
Copy link

mshap commented Aug 1, 2023

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.

@smilad
Copy link

smilad commented Oct 17, 2023

Merge it

@mooreds
Copy link
Contributor

mooreds commented Oct 23, 2023

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!

@mirobertod
Copy link

Hi guys, any update on this? We're facing the same issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants