[Bug] CLI commands (sanitize, normalize, templatize, export, import) exit with code 0 on failure
Is there an existing issue for this?
- I have searched and didn't find similar issue
Current behavior
When executing utility CLI commands like keploy sanitize, keploy normalize, keploy templatize, keploy export, or keploy import, if the service execution encounters an error (e.g., non-existent test-set directory or unparseable YAML), the error is logged using utils.LogError(), but Cobra's RunE returns nil.
Because RunE returns nil and utils.ErrCode remains 0, main() executes os.Exit(0). This causes CI/CD scripts and automated workflows to report success (exit code 0) even when the command completely fails to execute the intended operation.
What I expect is: When a CLI tool command fails, Cobra's RunE should return an error (or set utils.ErrCode = 1) so that main() exits with a non-zero exit code (1), signaling failure to CI/CD pipelines.
Steps to Replicate
- Run a CLI tool command targeting a non-existent test set: keploy sanitize -t "non-existent-test-set"
- Observe that an error message is printed to stdout/stderr: "failed to sanitize test cases".
- Check the process exit status in the shell:
- Linux/macOS: echo $?
- Windows PowerShell: $LASTEXITCODE
- Notice that the exit code is 0 (Success) instead of 1 (Failure).
###Logs (if any)
No response
Operating system
Windows
Source: keploy/keploy