Skip to content

Properly return a 1 when a threshold is not met#3299

Merged
em-c-rod merged 3 commits intomainfrom
return_code
Feb 19, 2025
Merged

Properly return a 1 when a threshold is not met#3299
em-c-rod merged 3 commits intomainfrom
return_code

Conversation

@wdower
Copy link
Contributor

@wdower wdower commented Feb 18, 2025

SAF CLI should exit with code 1 when a threshold is not met to enable other automation to properly handle its output without having to parse stderr.

Resolves #3298

Signed-off-by: Will <will@dower.dev>
@wdower wdower self-assigned this Feb 18, 2025
Signed-off-by: Will <will@dower.dev>
@sonarqubecloud
Copy link

} else {
this.warn(err)
console.error(err.message)
process.exit(1)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We tried using this.exit instead of process but it dumped the entire stack trace. What we want is a simple error message to stderr and the return code set correctly. Working within oclif doesn't seem to want to allow this.

@wdower wdower marked this pull request as ready for review February 19, 2025 18:32
Copy link
Contributor

@georgedias georgedias left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Until we hear from oclif I support using this work-around

@em-c-rod em-c-rod merged commit 09065ec into main Feb 19, 2025
17 checks passed
@em-c-rod em-c-rod deleted the return_code branch February 19, 2025 20:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

validate threshold does not properly exit with return code 1 when the threshold is not met

3 participants