Skip to content
This repository has been archived by the owner on Jun 18, 2024. It is now read-only.

Failing validation doesn't fail the export script or the workflow step #4

Open
WhiteFruit opened this issue Mar 28, 2023 · 2 comments

Comments

@WhiteFruit
Copy link

When the export.sh script runs node ./node_modules/@microsoft/azure-data-factory-utilities/lib/index validate $(pwd) $dataFactoryId on line 16, if the validation fails, the bash script does not fail - despite node throwing errors.

Because the script doesn't fail, the script continues on to the export step line 26. This command will inevitably also error out as the code isn't valid.

Because there is no error handling in the bash script, the step in the parent workflow that calls this action doesn't know that there were errors, and it shows in the GitHub workflow to have completed successfully.

This can be fixed by simply adding set -e explanation here at the top of the export.sh script. This will cause the bash script to exit at the first non-zero exit code reported by any command in the script, and will accurately report back to the parent workflow that the action has failed. If there are commands in the script that should continue on error, additional configuration would be needed to allow that when using set -e.

Alternatively, command conditionals could be wrapped around the validate and export commands to explicitly exit the script with a non-zero exit code.

@edstancu
Copy link

Any news on this improvement?:)
If there are validation errors found then the action should fail...

@WhiteFruit
Copy link
Author

WhiteFruit commented May 12, 2023

@edstancu In the short term, I've simply recreated this action in my own org and added set -e as the second line of the export.sh script (after #!/usr/bin/env bash). Unfortunately, it's my company's private org so I can't share it.

You could also use the Azure/data-factory-validate-action as it does have error handling of a sort: link here. In most cases, I wouldn't recommend using $? like they have in that action to ensure a previous command was successful, since a parent function could return a zero exit code even if something inside it returned a non-zero exit code. I can't test every scenario to find out if that might be the case here, so at the moment we just have to hope that the node module has correct error handling.

It's worth pointing out that if they fix the error handling here, the validate action is redundant and a waste of build minutes if you're also running this export action since the export action runs the validate function first.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants