Auth0 Custom Database Action Script PostgreSQL Template Returns "SandboxUnhandledError"

Overview

When using the Auth0 Custom Database Action Script PostgreSQL template, a connection error occurs because the script lacks an explicit Node package version. Specifying the exact version of the pg package in the script resolves this issue. The script fails to execute when selecting Save and Try, even after updating the script with custom Amazon Relational Database Service (RDS) PostgreSQL details.

Auth0 generates the following error:

 

[SandboxUnhandledError] postgres.connect is not a function

 

Applies To

  • Custom Database Action Scripts
  • PostgreSQL template
  • Node.js

Cause

The script lacks a specific version declaration for the pg package. The version must align with the active Node package runtime version in the Auth0 environment.

 

Solution

How is the PostgreSQL connection error resolved?

 

Update the script to include the specific Node runtime package version.

  1. Verify the accepted versions for the specific Node runtime by reviewing the Auth0 Extensions Can I Require documentation.
  2. Modify the require statement in the script to include the exact version.

For example:

const { Client } = require("pg@8.7.1")
 

Recommended content

No recommended content found...