Skip to content

Commit a4069a3

Browse files
ruromeroclaude
andauthored
fix(cargo): propagate timeout error with actionable message (guacsec#429)
## Summary - Propagates timeout and I/O errors as `RuntimeException` instead of silently logging them, ensuring callers are notified of failures - Adds system property hint (`-Dtrustify.cargo.timeout.seconds=N`) to timeout error message for easy adjustment Implements [TC-4165](https://redhat.atlassian.net/browse/TC-4165) ## Test plan - [x] All 29 existing Cargo tests pass (`CargoProviderTest`, `CargoSbomTest`) - [x] Timeout error message includes system property hint - [x] Errors propagate correctly through `addDependencies()` → `createSbom()` call chain - [ ] CI integration tests pass on cargo-stable scenario 🤖 Generated with [Claude Code](https://claude.com/claude-code) [TC-4165]: https://redhat.atlassian.net/browse/TC-4165?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent cddf65b commit a4069a3

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/main/java/io/github/guacsec/trustifyda/providers/CargoProvider.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,8 @@ private void addDependencies(
147147
}
148148

149149
} catch (IOException | InterruptedException e) {
150-
log.severe("Unexpected error during " + analysisType + " analysis: " + e.getMessage());
150+
throw new RuntimeException(
151+
"Failed during " + analysisType + " analysis: " + e.getMessage(), e);
151152
}
152153
}
153154

@@ -438,7 +439,10 @@ private CargoMetadata executeCargoMetadata() throws IOException, InterruptedExce
438439
process.destroyForcibly();
439440
outputFuture.cancel(true);
440441
errorFuture.cancel(true);
441-
throw new InterruptedException("cargo metadata timed out after " + TIMEOUT + " seconds");
442+
throw new InterruptedException(
443+
"cargo metadata timed out after "
444+
+ TIMEOUT
445+
+ " seconds. Adjust with -Dtrustify.cargo.timeout.seconds=N");
442446
}
443447

444448
try {

0 commit comments

Comments
 (0)