SWA CLI exits 0 even when deployment fails
Are you accessing the CLI from the default port :4280 ?
- [ ] No, I am using a different port number (
--port) and accessing the CLI from that port - [x] Yes, I am accessing the CLI from port
:4280
Describe the bug
When the StaticSitesClient fails with an unknown exception, the error is logged but the swa cli exits with a status of 0 indicating success. This is misleading and causes automated processes like CI runs to report success even though the deployment failed.
To Reproduce
Attempt to deploy a SWA using version 1.1.5 per #776. You will see the error An unknown exception has occurred printed, and then the program will exit 0.
Expected behavior
The swa cli should exit with a non-zero status code, indicating failure.
Screenshots
(Note that
$? returns the exit code of the previous command)
Desktop (please complete the following information):
- OS: Ubuntu
- Version: 22.04.3
Additional context I believe this is the offending code block: https://github.com/Azure/static-web-apps-cli/blob/b2123b9c93b694593bf0a48288cd1fb28d481bc1/src/cli/commands/deploy/deploy.ts#L328-L339
Either line 329 needs to set the exit parameter to true, or an else could be added to the if statement starting line 335 that handles the case when code is not zero. Without access to the source code of StaticSitesClient I don't feel comfortable opening a PR for this, as I can't confirm the expected behaviour of that binary blob.
I added the root cause in https://github.com/Azure/static-web-apps-cli/pull/778, sorry for the issue and thanks to help investigate it.
I am also seeing this on the CI/CD when there is an error like: ✖ Failed to validate staticwebapp.config.json schema. Is it on purpose that swa cli exits with a zero code?