fix: throw error on gradle command failure instead of returning empty…#362
Conversation
Review Summary by QodoFix Gradle provider to throw errors on command failure
WalkthroughsDescription• Replace runProcessGetOutput() with runProcessGetFullOutput() to capture exit codes • Throw RuntimeException when Gradle commands fail instead of silently returning empty SBOM • Add null-safety defaults in getRoot() for missing properties • Add comprehensive test coverage for Gradle command failures Diagramflowchart LR
A["Gradle Command Execution"] -->|Previously| B["runProcessGetOutput<br/>ignores exit code"]
A -->|Now| C["runProcessGetFullOutput<br/>captures exit code"]
B --> D["Silent Failure<br/>Empty SBOM"]
C --> E{"Exit Code == 0?"}
E -->|Yes| F["Return Output"]
E -->|No| G["Throw RuntimeException<br/>with error details"]
H["Missing Properties"] -->|Now| I["Use Defaults<br/>unknown/0.0.0"]
File Changes1. src/main/java/io/github/guacsec/trustifyda/providers/GradleProvider.java
|
Code Review by Qodo
1.
|
src/main/java/io/github/guacsec/trustifyda/providers/GradleProvider.java
Show resolved
Hide resolved
|
Could you take a look at the qodo review comments ? look like legitimate to me |
|
could you also fix the potential temp files leak on errors ? thanks |
soul2zimate
left a comment
There was a problem hiding this comment.
@a-oren thanks for the quick fixes, but the changes fail gradle- related integration tests in CI due to the timeout.
30ce9f9 to
b8b2836
Compare
… sbom
Description
GradleProvider used Operations.runProcessGetOutput() which never checked
the process exit code. When Gradle evaluation failed (e.g., unresolvable
version catalogs), the error was silently ignored and an empty SBOM was
returned to the user.
Switched getDependencies() and getProperties() to use
runProcessGetFullOutput() which properly captures stdout, stderr, and
exit code. Non-zero exit codes now throw a RuntimeException with the
Gradle error message.
Also added null-safety defaults in getRoot() for edge cases with
partial properties output.
Related issue (if any): fixes #361
Checklist
Additional information