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
248 stars 155 forks source link

[DIRECTORY/JSON format] Actions secrets keyword javascript error during export #955

Closed TimeTravelerFromNow closed 1 month ago

TimeTravelerFromNow commented 2 months ago

Checklist

Description

PR with the fix PR 954 If a placeholder such as @@SECRETS@@ is used in place of the secrets array in the JSON export directory such as exports/web_app/actions/post_change_password_invalidate_sessions.json, the export cli fails with the error

2024-09-06T21:15:03.444Z - debug: TypeError: secrets.map is not a function
    at mapSecrets (/Users/sebastiandetering/.nvm/versions/node/v20.12.2/lib/node_modules/auth0-deploy-cli/lib/context/directory/handlers/actions.js:49:24)
    at mapToAction (/Users/sebastiandetering/.nvm/versions/node/v20.12.2/lib/node_modules/auth0-deploy-cli/lib/context/directory/handlers/actions.js:73:18)

Related to, but not the same error as this issue for YAML actions secrets placeholder preservation.

Expectation

Expected the export to succeed, and for the @@SECRETS@@ placeholder to be preserved. Instead of error secrets.map is not a function being thrown.

Reproduction

  1. Begin with a tenant that contains an Auth0 action.
  2. Export from a tenant using the --format directory.
  3. View the directory output, and manually edit the json file for this action to have the "secrets": [] array use a placeholder value instead. "secrets": "@@MY_SECRETS@@"
  4. Define the placeholder preservation in your config file used for your export, simple example below exports/webapp/myconfig.json
    {
    "AUTH0_ALLOW_DELETE": true,
    "AUTH0_PRESERVE_KEYWORDS": true,
    "AUTH0_KEYWORD_REPLACE_MAPPINGS": {
    "MY_SECRETS": [
      {
        "name": "M_TO_M_APP_DOMAIN",
        "value": "##AUTH0_DOMAIN##"
      }
    ]
    }
    }
  5. Next, perform the export again with this config file
    a0deploy export \
    --strip \
    --format directory \
    --output_folder ./exports/webapp \
    --config_file ./exports/webapp/myconfig.json \
    --debug true
  6. The error should occur
    2024-09-06T21:15:03.444Z - debug: TypeError: secrets.map is not a function
    at mapSecrets (/Users/sebastiandetering/.nvm/versions/node/v20.12.2/lib/node_modules/auth0-deploy-cli/lib/context/directory/handlers/actions.js:49:24)
    at mapToAction (/Users/sebastiandetering/.nvm/versions/node/v20.12.2/lib/node_modules/auth0-deploy-cli/lib/context/directory/handlers/actions.js:73:18)

Deploy CLI version

7.24.2

Node version

20.12.2

TimeTravelerFromNow commented 1 month ago

Thanks @kushalshit27 for helping getting this issue fixed.

Posting the steps I followed to fetch the latest version

This should install the latest version 7.24.3, checking with

I ran a tenant config export this morning and am no longer experiencing the issue. ...

2024-10-17T16:13:27.966Z - info: Export Successful
2024-10-17T16:13:27.966Z - info: 
  ================================================
  ======= Help us improve Auth0 Deploy CLI =======
  ================================================
  We're on a mission to make Auth0 Deploy CLI the best it can be, and we need YOUR help.
  We've put together a brief survey to understand how you use Deploy CLI, what you love about it, and where you think we can do better.

  ===> https://www.surveymonkey.com/r/LZKMPFN  <===

  Thank you for helping us make Auth0 Deploy CLI better for everyone!
  ================================================