auth0-deploy-cli icon indicating copy to clipboard operation
auth0-deploy-cli copied to clipboard

Looking for action file in root folder during import

Open schazza opened this issue 1 year ago • 2 comments

Checklist

  • [X] I have looked into the README and have not found a suitable solution or answer.
  • [X] I have looked into the documentation and have not found a suitable solution or answer.
  • [X] I have searched the issues and have not found a suitable solution or answer.
  • [X] I have upgraded to the latest version of this tool and the issue still persists.
  • [X] I have searched the Auth0 Community forums and have not found a suitable solution or answer.
  • [X] I agree to the terms within the Auth0 Code of Conduct.

Description

Since updating to 7.20.0 I get the following error when trying to import (a0deploy import --input_file ./src --config_file ./config/config-file.json): Unable to load file C:\Git\auth0-cicd\src\code.js due to Error: ENOENT: no such file or directory, access 'C:\Git\auth0-cicd\src\code.js'

Expectation

The import should work with this command without a code.js file in the src folder. Alternatively if this file is required some information on what it should include should have been added in the release notes for 7.20.0.

Reproduction

  1. Given a source folder that a repo has been exported to on version 7.18.0
  2. When running the command a0deploy import --input_file ./src --config_file ./config/config-file.json
  3. Then the tenant should be updated

Deploy CLI version

7.20.0

Node version

18.17.1

schazza avatar Dec 12 '23 13:12 schazza

As noted by the changelog for 7.20.0, there was added support for actions code files to be imported relative to the configuration file (#866). There must've been a regression included in that.

Looking closer, there is a loadFile function that allows for an absolute path or a path relative to the actions folder. The code that was added in #866 only accounts for the latter of the cases, which may explain this bug. Especially since you nest the config file in a config directory. I'm unable to recreate your specific issue, can you provide the action configuration file and the path of the exported code.js file?

willvedd avatar Dec 13 '23 21:12 willvedd

Thanks for a fast response.

We have three actions that all look roughly like this:

{
  "name": "Add roles to ID token",
  "code": "code.js",
  "runtime": "node18",
  "status": "built",
  "dependencies": [],
  "secrets": [],
  "supported_triggers": [
    {
      "id": "post-login",
      "version": "v2"
    }
  ],
  "deployed": true
}

Path to the action configuration file is C:\Git\auth0-cicd\src\actions\Add roles to ID token.json Path to the code.js file is C:\Git\auth0-cicd\src\actions\Add roles to ID token\code.js

We set this up following this example: https://github.com/auth0/auth0-deploy-cli/tree/master/examples/directory/actions

schazza avatar Dec 14 '23 08:12 schazza