Skip to content

fix: fetch enabled_clients from the dedicated endpoint#1532

Merged
ramya18101 merged 6 commits into
auth0:mainfrom
davidlovas:fix/nil-enabled-clients-check
Jun 6, 2026
Merged

fix: fetch enabled_clients from the dedicated endpoint#1532
ramya18101 merged 6 commits into
auth0:mainfrom
davidlovas:fix/nil-enabled-clients-check

Conversation

@davidlovas
Copy link
Copy Markdown
Contributor

@davidlovas davidlovas commented May 27, 2026

Bug

auth0 users create fails with "There are currently no active database or passwordless connections to choose from" when a connection has enabled_clients: null (the default, meaning enabled for all applications).

Root cause

GetEnabledClients() returns nil when enabled_clients is null in the API response. Instead we use the different API (connections/{id}/clients) to fetch the enabled_clients

Fix

Use dedicated ConnectionManager.ReadEnabledClients instead of GetEnabledClients()

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: null on the Username-Password-Authentication connection:

Command Stock CLI (1.31.0) Patched CLI
auth0 api post "users" --data '{...}' Succeeds Succeeds
auth0 users create -c "Username-Password-Authentication" ... Fails Succeeds

Same connection, same tenant — the Management API works, the users create wrapper does not.

Environment

  • CLI version: 1.31.0 (also reproduced on 1.29.0)
  • OS: macOS (Darwin, arm64)
  • Connection: Username-Password-Authentication with enabled_clients: null

@davidlovas davidlovas marked this pull request as ready for review May 29, 2026 03:01
@davidlovas davidlovas requested a review from a team as a code owner May 29, 2026 03:01
@ramya18101
Copy link
Copy Markdown
Contributor

Hello @davidlovas ,

Thanks for raising the PR, We'll look into it and get back soon!

@davidlovas davidlovas force-pushed the fix/nil-enabled-clients-check branch from 65669a0 to 0515b5d Compare June 1, 2026 04:11
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.
@davidlovas davidlovas force-pushed the fix/nil-enabled-clients-check branch from 0515b5d to 0625dba Compare June 1, 2026 17:26
@ramya18101
Copy link
Copy Markdown
Contributor

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, enabled_clients from the connection CRUD APIs is deprecated, so we shouldn’t rely on that field here even if nil is interpreted differently. The source of truth should come from the new endpoint instead.

Could we switch this logic to the replacement endpoint instead of adding more handling around the deprecated enabled_clients field?

…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.
@davidlovas
Copy link
Copy Markdown
Contributor Author

Thanks for the guidance @ramya18101! You're right, I've updated the PR to use the dedicated ReadEnabledClients endpoint (GET /api/v2/connections/{id}/clients) instead of the deprecated enabled_clients field. The go-auth0 SDK already has ConnectionManager.ReadEnabledClients so it was a clean switch.

@ramya18101
Copy link
Copy Markdown
Contributor

Thanks for the quick change!

We also no longer need the nil check. The ReadEnabledClients endpoint (GET /api/v2/connections/{id}/clients) already handles fetching the default client, so if a valid application is returned in that enabled list, the user creation flow will succeed.

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.

@davidlovas
Copy link
Copy Markdown
Contributor Author

davidlovas commented Jun 5, 2026

Acknowledged, simplified and removed the nil check.

@ramya18101 ramya18101 changed the title fix: treat nil enabled_clients as enabled for all applications fix: fetch enabled_clients from ReadEnabledClients for all applications Jun 6, 2026
@ramya18101 ramya18101 changed the title fix: fetch enabled_clients from ReadEnabledClients for all applications fix: fetch enabled_clients from the dedicated endpoint Jun 6, 2026
@ramya18101
Copy link
Copy Markdown
Contributor

ramya18101 commented Jun 6, 2026

I've updated the PR description and title!

@ramya18101
Copy link
Copy Markdown
Contributor

@davidlovas , Can you please fix the linter errors

@ramya18101 ramya18101 enabled auto-merge (squash) June 6, 2026 07:20
@ramya18101 ramya18101 merged commit a9323df into auth0:main Jun 6, 2026
6 checks passed
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.

2 participants