Skip to content

fix: treat nil enabled_clients as enabled for all applications#1532

Open
davidlovas wants to merge 1 commit into
auth0:mainfrom
davidlovas:fix/nil-enabled-clients-check
Open

fix: treat nil enabled_clients as enabled for all applications#1532
davidlovas wants to merge 1 commit into
auth0:mainfrom
davidlovas:fix/nil-enabled-clients-check

Conversation

@davidlovas
Copy link
Copy Markdown

@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. In Go, len(nil) == 0 evaluates to true, so the CLI treats connections enabled for all apps identically to connections explicitly disabled (empty slice).

Fix

Distinguish between nil (all apps, no restriction) and empty slice (explicitly disabled):

// Before
if len(connection.GetEnabledClients()) == 0 {

// After
if enabledClients := connection.GetEnabledClients(); enabledClients != nil && len(enabledClients) == 0 {

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

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 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!

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