Skip to content
This repository has been archived by the owner on Feb 16, 2022. It is now read-only.

Empty lists arnt being serialized in the JSON sent to auth0 #74

Closed
bishtawi opened this issue Sep 25, 2019 · 3 comments
Closed

Empty lists arnt being serialized in the JSON sent to auth0 #74

bishtawi opened this issue Sep 25, 2019 · 3 comments

Comments

@bishtawi
Copy link
Contributor

All of the structs in this codebase uses pointers instead of primitives. I assume this was because the JSON option omitempty would omit empty values (false, 0, empty string) from being serialized, preventing the library from being able to sending empty values to Auth0.

The one exception to the all pointer convention is lists. Lists in the structs are actual lists, []interface{}, instead of pointer to lists, *[]interface{}. This makes it impossible to send an empty list to auth0.

I dont know the full impact on changing all lists to be pointer to lists, or updating all lists to remove the omitempty tag, but something has got to give as currently its impossible to send an empty list.

@bishtawi
Copy link
Contributor Author

bishtawi commented Sep 25, 2019

Look like in #29 there was a one-off to remove omitempty from the scope list, which got merged. And another one-off at #43 to remove omitempty from the client struct, which hasnt merged yet. Some good discussion in that last PR; looks like this is an already know issue without a solution yet.

Whatever solution we go with, it should be applied to all lists in all structs and not be one-off solutions.

@alexkappa
Copy link
Contributor

I agree Stephen, we should indeed be consistent with all these. For what its worth the reason why I agreed to merge #29 was due to it being required in POST and PATCH requests.

The thing is, I haven't seen another SDK use pointers for slices and maps so far, and I suspect there's a good reason for that. Also, the added complexity of slices and maps having arbitrary types, it would make helper methods impossible to implement (e.g. the slice equivalent of auth0.String(...)).

@alexkappa
Copy link
Contributor

Closing this as there is no plan to tackle this particular use case directly in the SDK. But, using the newly exposed Request & co methods you should be able to send any custom payload to the management API to overcome this issue.

See: #148

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

No branches or pull requests

2 participants