Configuration Discrepancies and Script Errors in Custom Database Connections

Overview

This article addresses a discrepancy in which some environments display an Attributes tab, while others show a Requires Username toggle in the database connection settings. It also clarifies why a password reset script fails with the following error:

 

DB get_user Custom script: id is required, please update the import user script in the connection settings.

 

Applies To

  • Custom Database Connections
  • Flexible Identifiers
  • Password Reset Flow

Cause

The discrepancy in the user interface occurs because the New Attributes Configuration, also known as Flexible Identifiers, is enabled in some environments but not others.

When Flexible Identifiers are active, the system enforces stricter validation on the get_user custom script. The script must return a value user_id within the profile object to identify the user, even if the user migration feature is disabled.

Solution

To align the environments or resolve the script error, follow these procedures:

Aligning Tenant Configurations

To enable Flexible Identifiers in a tenant showing the legacy view:

  1. Go to Database Connection > Attributes.

  2. Locate the banner titled New Attributes Configuration.

New Attributes Configuration

  1. Click Activate.

 

To roll back a tenant to the legacy view using the Management Application Programming Interface (API):

  1. Retrieve the current connection details using the Get a connection endpoint.
  2. Prepare a Patch a connection request.
  3. In the request body, remove the attributes key from the existing options object. This key tells Auth0 that this connection is using Flexible Identifiers.
  4. Remove the strategy, id, and name keys from the payload to avoid a 400 error.

NOTE: Include all other fields retrieved when establishing the connection, as deleting any of them results in inconsistent settings on the connection.

 

Resolving the Script Error

If Flexible Identifiers remain enabled, update the get_user or getByEmail script to return a user_id:

  1. Open the custom database script editor.
  2. Modify the callback to include a unique identifier.
// Before
function getByEmail (email, callback) {
  return callback(null, { email: email});
}

// After
function getByEmail (email, callback) {
  return callback(null, {
    user_id: 'legacy_' + email, 
    email: email
  });
}

NOTE: This code is for example purposes and must be tested in a development environment before use in production.

  1. Click Save.

 

Related References

Recommended content

No recommended content found...