Skip to content

TypeError: Cannot read properties of undefined (reading 'includes') when importing databases with AUTH0_EXCLUDED_CLIENTS and legacy enabled_clients toggle off #1363

@rickpasetto

Description

@rickpasetto

Checklist

  • I have looked into the README and have not found a suitable solution or answer.
  • I have looked into the documentation and have not found a suitable solution or answer.
  • I have searched the issues and have not found a suitable solution or answer.
  • I have upgraded to the latest version of this tool and the issue still persists.
  • I have searched the Auth0 Community forums and have not found a suitable solution or answer.
  • I agree to the terms within the Auth0 Code of Conduct.

Description

After opting out of the "Legacy Management of Connection's Enabled Clients" migration toggle (Tenant Settings > Advanced > Migrations), running a0deploy import with AUTH0_EXCLUDED_CLIENTS configured in the config JSON crashes during processChanges for the databases type:

error: Problem running command import during stage processChanges when processing type databases
error: Cannot read properties of undefined (reading 'includes')

Root cause:

In lib/tools/utils.js, the getEnabledClients function accesses conn.enabled_clients.includes(...) without a null/undefined check:

existing.forEach((conn) => {
    if (conn.name === connection.name) {
        excludedClients.forEach((excludedClient) => {
            if (conn.enabled_clients.includes(excludedClient)) {  // <-- crashes here
                enabledClients.push(excludedClient);
            }
        });
    }
});

When the legacy toggle is off, the Auth0 Management API no longer returns enabled_clients on connection objects. The databases.js handler's getType() method fetches enabled clients via the new dedicated endpoint and assigns them, but only when the returned array is non-empty. If the array is empty or the response shape differs, conn.enabled_clients remains undefined, causing the crash when combined with AUTH0_EXCLUDED_CLIENTS.

Suggested fix:

if (conn.enabled_clients?.includes(excludedClient)) {

Related issue: #1353 — similar TypeError: Cannot read properties of undefined in processChanges, also likely stemming from the node-auth0 v4→v5 transition and the move to dedicated connection endpoints.

Expectation

a0deploy import should complete successfully when:

  • The tenant's "Legacy Management of Connection's Enabled Clients" migration toggle is off (opted out of legacy behavior, per Auth0's migration guidance)
  • AUTH0_EXCLUDED_CLIENTS is configured in the config JSON
  • The databases section in tenant.yaml includes enabled_clients

Reproduction

  1. Configure AUTH0_EXCLUDED_CLIENTS in your .config.json with at least one client name
  2. Have a databases section in your tenant.yaml with enabled_clients defined on at least one database connection
  3. In the Auth0 Dashboard, go to Tenant Settings > Advanced > Migrations
  4. Toggle off "Legacy Management of Connection's Enabled Clients"
  5. Run a0deploy import -c config.json -i tenant.yaml
  6. Observe the crash at the databases processChanges stage

Deploy CLI version

8.31.0

Node version

v25.8.2

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions