Skip to content

Can not remove all clients from a connection #19

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

Closed
sergiught opened this issue Feb 16, 2022 · 2 comments
Closed

Can not remove all clients from a connection #19

sergiught opened this issue Feb 16, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@sergiught
Copy link
Contributor

From auth0 created by mvanderlee: go-auth0/auth0#241

Description

Setting c.EnabledClients to an empty list causes it to be omitted from the actual update request and thus the field is not actually updated.

This is because omitempty omits empty slices as well. As found in EnabledClients []interface{} json:"enabled_clients,omitempty".
This appears to be related to golang/go#22480

I'm not familiar with GoLang, but maybe there is a way to omit nil in the MarshalJSON function in connection.py?

Package Version

v5.19.2

Affected Resources

  • management.Connection

Sample Code

c := &management.Connection{
  EnabledClients = []interface{}
}
err = api.Connection.Update(connId, c, management.Context(ctx))

Expected Behavior

Should set EnabledClients to an empty list. i.e.: disable the connection for all clients

Actual Behavior

EnabledClients update is ignored, or if it's the only property set, the request actually fails.

Output

Error: 400 Bad Request: Payload validation error: 'Too few properties defined (0), minimum 1'

References

golang/go#22480

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment
@mbarrien
Copy link

Also see auth0/terraform-provider-auth0#14 for references to other cases where the omitempty is the same underlying issue.

@sergiught
Copy link
Contributor Author

Closing this as this has now been fixed with https://github.com/auth0/go-auth0/releases/tag/v0.11.0.

To empty out all the clients from a connection we need to send the following payload.

noEnabledClients := make([]string, 0)
connection := &management.Connection{EnabledClients: &noEnabledClients}
api.Connection.Update(connection.GetID(), connection)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants