auth0/auth0-deploy-cli

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

Closed this issue · 1 comments

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

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##"
      }
    ]
  }
}
  1. 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
  1. 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

Thanks @kushalshit27 for helping getting this issue fixed.

Posting the steps I followed to fetch the latest version

  • npm install -g auth0-deploy-cli

This should install the latest version 7.24.3, checking with

  • npm view auth0-deploy-cli
    The first line of output from this command shows the version
    auth0-deploy-cli@7.24.3 | MIT | deps: 13 | versions: 173

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!
  ================================================