fix: fetch enabled_clients from the dedicated endpoint#1532
Conversation
|
Hello @davidlovas , Thanks for raising the PR, We'll look into it and get back soon! |
65669a0 to
0515b5d
Compare
When enabled_clients is null in the API response (meaning the connection is enabled for all applications), GetEnabledClients() returns nil. len(nil) == 0 in Go, so the CLI incorrectly skips these connections, producing "no active database or passwordless connections" errors. This fix distinguishes between nil (all apps, no restriction) and an empty slice (explicitly disabled for all apps). Only the latter should be treated as disabled. Fixes all 3 occurrences in users.go: createUserCmd, importUsersCmd, and databaseAndPasswordlessConnectionOptions.
0515b5d to
0625dba
Compare
|
Thanks for the fix, this improves the nil vs empty handling, but I don’t think it addresses the actual migration requirement. Per the migration docs, Could we switch this logic to the replacement endpoint instead of adding more handling around the deprecated |
…ients field
Replace connection.GetEnabledClients() with the dedicated
ReadEnabledClients endpoint per the Auth0 migration guide.
The enabled_clients field on connections is deprecated and
will be removed in a future API version.
Adds ReadEnabledClients to ConnectionAPI interface and uses
a helper function to check client associations via the new
GET /api/v2/connections/{id}/clients endpoint.
|
Thanks for the guidance @ramya18101! You're right, I've updated the PR to use the dedicated |
|
Thanks for the quick change! We also no longer need the nil check. The ReadEnabledClients endpoint ( Internally, the core logic treats both nil and [] the same way: as zero enabled clients. Using this endpoint lets us avoid manually distinguishing between those cases. I tested it, and it works. |
|
Acknowledged, simplified and removed the nil check. |
|
I've updated the PR description and title! |
|
@davidlovas , Can you please fix the linter errors |
Bug
auth0 users createfails with "There are currently no active database or passwordless connections to choose from" when a connection hasenabled_clients: null(the default, meaning enabled for all applications).Root cause
GetEnabledClients()returnsnilwhenenabled_clientsis null in the API response. Instead we use the different API (connections/{id}/clients) to fetch theenabled_clientsFix
Use dedicated
ConnectionManager.ReadEnabledClientsinstead ofGetEnabledClients()Applied to all 3 occurrences in
internal/cli/users.go:createUserCmd()(line 407)importUsersCmd()(line 897)databaseAndPasswordlessConnectionOptions()(line 999)Tested
Built the patched CLI locally and verified against a tenant with
enabled_clients: nullon theUsername-Password-Authenticationconnection:auth0 api post "users" --data '{...}'auth0 users create -c "Username-Password-Authentication" ...Same connection, same tenant — the Management API works, the
users createwrapper does not.Environment
Username-Password-Authenticationwithenabled_clients: null