Skip to content

Commit 7636b1b

Browse files
committed
fix(cargo): propagate timeout error and increase default from 5s to 120s
The 5-second default was insufficient for initial crates.io index downloads, especially on Windows CI. Errors were silently swallowed in addDependencies(), producing empty SBOMs instead of reporting failures. Now timeout errors propagate as RuntimeException with a message that references the trustify.cargo.timeout.seconds system property so users know how to adjust it. Implements TC-4165 Assisted-by: Claude Code
1 parent cddf65b commit 7636b1b

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public final class CargoProvider extends Provider {
7272
private static final String PACKAGE_VERSION_WORKSPACE = "package.version.workspace";
7373
private static final String WORKSPACE_PACKAGE_VERSION = "workspace.package.version";
7474
private static final long TIMEOUT =
75-
Long.parseLong(System.getProperty("trustify.cargo.timeout.seconds", "5"));
75+
Long.parseLong(System.getProperty("trustify.cargo.timeout.seconds", "120"));
7676
private final String cargoExecutable;
7777

7878
private CargoProjectLayout getProjectLayout(CargoMetadata metadata) {
@@ -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)