auth0-deploy-cli
                                
                                
                                
                                    auth0-deploy-cli copied to clipboard
                            
                            
                            
                        Incorrect path delimiter used when exporting actions on Windows
Description
When exporting a tenant with a action on Windows, the JSON metadata uses the Windows path delimiter (\) within the "code" field. This is fine if you then re-run the import on Windows again, however, for teams that use multiple OSs
(and also CI/CD pipelines running Linux) this becomes a problem as the following error is displayed when running the import:
error: Unable to load file /opt/atlassian/pipelines/agent/build/auth0\actions\action-name\code.js due to Error: ENOENT: no such file or directory, access '/opt/atlassian/pipelines/agent/build/auth0\actions\action-name\code.js'
Example of json file
{
  "name": "action-name",
  "code": "auth0/actions/action-name/code.js",
  "runtime": "node16",
  "status": "built",
  "dependencies": [],
  "supported_triggers": [
    {
      "id": "credentials-exchange",
      "version": "v2"
    }
  ],
  "deployed": true
}
Reproduction
- Create a tenant with an action
 - Export the tenant using a0deploy on a Windows OS
 - Import the tenant using a0deploy on a none Windows OS
 
Environment
Please provide the following:
- Version of this library used: 7.2.0
 - Version of the platform or framework used, if applicable: Windows/Ubuntu Linux
 
I noticed the same behaviour and was curious why rules could be exported correctly with unix style path on windows while actions wouldn't (the rule json references the .js file with ./rulename.js path. Looking at the code I see that this is hardcoded here: https://github.com/auth0/auth0-deploy-cli/blob/679117d0d53b88a566cecbf91b39d2955820e7a0/src/context/directory/handlers/rules.js#L46 while the code for actions generates the path using path.join: https://github.com/auth0/auth0-deploy-cli/blob/679117d0d53b88a566cecbf91b39d2955820e7a0/src/context/directory/handlers/actions.js#L46
I'm by no means a NodeJS expert, but it seems you can use the posix version of the path module even on windows to get consistent behaviour on both: https://nodejs.org/api/path.html#windows-vs-posix
It feels like the best solution would be to use the posix version everywhere (or at least where paths are generated to be used in any .json files)?
Perhaps replace all:
import path from 'path';
with:
import { posix: path } from 'path';
                                    
                                    
                                    
                                
Is there any update to this? The development team uses Windows here while deployments happen in Linux. This is a frustrating issue...
It would be great to support Windows machines. And assuming the above solution works, this should be a straightforward fix. However, I do not have a practical means of testing it so perhaps someone with a Windows machine could test the proposed changes and create a PR. Otherwise I see this sitting for a little while.
Hey folks, we fixed this in https://github.com/auth0/auth0-deploy-cli/pull/668 and it will be available in the next release. Appreciate everyone's patience!
Update: After investigation it has been determined that this issue is only scoped to actions and when the operating systems of the machines that performed the import differs from that of the machine that did the export. Meaning, this issue won't be experience if a windows machine performs both the export and the import.
The fix has been released with 7.15.1. It converts the path at runtime to support both windows and unix machines. Doing so maintains backwards-compatibility and won't necessitate a new export of your actions.
Otherwise, we don't have reason to believe that any other Windows issues exist at this time. If anyone is still having issues after updating, please feel empowered to open a new ticket.