auth0 / auth0-deploy-cli

The Auth0 Deploy CLI is a tool that helps you manage your Auth0 tenant configuration. It integrates into your development workflows as a standalone CLI or as a node module.
MIT License
236 stars 147 forks source link

Auth0 cli dependencies error #874

Open Gentracker1 opened 6 months ago

Gentracker1 commented 6 months ago

Checklist

Description

Hello, We are using auth0-cli as a node-module to export the data. We have tried with [7.20.0][7.19.0]....[7.11.0] versions, but same error.

Environment WSL on windows, Ubuntu-22.04 Node v18.16.0 Using Typescript Version 4.9.5 Using Auth0-cli in AWS Lambda (import { dump } from 'auth0-deploy-cli';)

Package.json "auth0": "4.0.1", "auth0-deploy-cli": "7.20.0"

Lambda code import { Connection, ManagementClient, PostUsersExportsRequest, GetOrganizationMemberRoles200ResponseOneOfInner, } from "auth0"; import { dump } from 'auth0-deploy-cli';

//start dump clients dump({ output_folder: '/tmp/auth0-config/export/directory"', format: 'directory', config: { AUTH0_DOMAIN: secrets.domain, AUTH0_CLIENT_ID: secrets.client_id, AUTH0_CLIENT_SECRET: secrets.client_secret, }, }) .then(() => { console.log('Auth0 configuration export successful'); }) .catch((err) => { console.log('Error during Auth0 configuration export:', err); }); //end dump

Steps:

npm install

npm run build "build": npm run functions:build, "functions:build": "tsc -p functions",

https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_lambda_nodejs.NodejsFunction.html Node.js Lambda function bundled using esbuild.

suhailt@GTKNZ072:~/Project/platform-auth0$ npm run build

platform-auth0@1.0.0 build npm run functions:build

platform-auth0@1.0.0 functions:build tsc -p functions

node_modules/promise-pool-executor/index.d.ts:5:31 - error TS2305: Module '"promise-batcher"' has no exported member 'BatcherToken'.

5 export { BATCHER_RETRY_TOKEN, BatcherToken, BatchingResult } from "promise-batcher";



Found 1 error in node_modules/promise-pool-executor/index.d.ts:5
`

### Expectation

Able to deploy the lambda with the auth0-cli.

### Reproduction

With node Node v18.16.0
Using Typescript Version 4.9.5
Use the latest [7.20.0](https://github.com/auth0/auth0-deploy-cli/releases/tag/v7.20.0)

Deploy the AWS lambda 
npx cdk deploy <Stack>

### Deploy CLI version

7.20.0

### Node version

v18.16.0
m3talsmith commented 6 months ago

@Gentracker1 can you reproduce this locally? Or only on lambda?

If only on lambda, are you using the default image for AWS Node? If not, is it an image we can use to reproduce?

I did write a small test to try it locally and couldn't reproduce the error. I'm trying to get as close to your setup as possible. The lambda environment is my main unknown. I'm happy to dig in more if you could get me that info.

Gentracker1 commented 6 months ago

auth0-720

Gentracker1 commented 6 months ago

Updated with the more info and updated the auth0/auth0-cli to the latest version. The error with the latest version is at npm run build.

We are using the WSL Ubuntu with AWS CDK,

Gentracker1 commented 6 months ago

@m3talsmith I have updated the error desc, we are using the latest auth0-cli. Thanks

m3talsmith commented 6 months ago

@Gentracker1 I was able to reproduce the promise-batcher error. Will have a work around for you soon.

m3talsmith commented 6 months ago

@Gentracker1 what happens if you add this to your dependencies:

"promise-batcher": "1.0.1"
Gentracker1 commented 6 months ago

Thanks @m3talsmith . After installing promise-batcher, I was able to build and deploy the lambda. On executing the lambda, it gives the below error. { "errorType": "TypeError", "errorMessage": "hexoid is not a function", "trace": [ "TypeError: hexoid is not a function", " at node_modules/formidable/src/Formidable.js (/var/task/index.js:68166:20)", " at __require (/var/task/index.js:12:50)", " at node_modules/formidable/src/index.js (/var/task/index.js:69025:22)", " at __require (/var/task/index.js:12:50)", " at node_modules/superagent/lib/node/index.js (/var/task/index.js:73799:22)", " at __require (/var/task/index.js:12:50)", " at node_modules/rest-facade/src/Client.js (/var/task/index.js:116198:19)", " at __require (/var/task/index.js:12:50)", " at node_modules/rest-facade/src/index.js (/var/task/index.js:116454:15)", " at __require (/var/task/index.js:12:50)" ] }

matthewhgentrack commented 5 months ago

Found a similar error for "hexoid" is not a function here: https://github.com/auth0/node-auth0/issues/798 Suggestions for a fix there seem to relate to webpack. Not sure how to resolve for AWS CDK/NodeJsFunction which is bundling via esbuild.

matthewhgentrack commented 5 months ago

Overriding the superagent version for rest-facade in package.json seems to workaround the problem.

"overrides": {
    "rest-facade": {
      "superagent": "6.0.0"
    }
  }

Not an ideal solution to override dependencies though.

m3talsmith commented 5 months ago

Tracking down hexoid and superagent errors now @Gentracker1 and @matthewhgentrack

m3talsmith commented 5 months ago

This definitely comes down to transitive dependencies of node-auth. Specifically, it comes down to formidable via superagent as @matthewhgentrack points out. A workaround seems to be to downgrade superagent or save the latest formidable to your npm packages.

MrOctopus commented 4 months ago

The fix is simple: Don't add add an old promise-batcher version to your direct dependencies. Do an override of the peer dependency itself: "overrides": { "promise-pool-executor": { "promise-batcher": "1.0.2" } } To avoid the hexoid issue, just make sure to use the newest auth0 3.* version (v3.7.2).