Azure / static-web-apps-cli

Azure Static Web Apps CLI ✨
https://aka.ms/swa/cli-local-development
MIT License
596 stars 117 forks source link

SWA CLI exits 0 even when deployment fails #777

Closed nimro closed 10 months ago

nimro commented 10 months ago

Are you accessing the CLI from the default 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 image (Note that $? returns the exit code of the previous command)

Desktop (please complete the following information):

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.

cjk7989 commented 10 months ago

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.