Skip to content

Commit

Permalink
fix(SBOMER-166): proper handling of umb notifications for non-product…
Browse files Browse the repository at this point in the history
…-related manifests

Failure in sending messages for non-product related manifests should not
be fatal.
  • Loading branch information
goldmann committed Sep 27, 2024
1 parent 31e3b5f commit 69325f2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,8 @@ protected UpdateControl<GenerationRequest> reconcileGenerating(
generationRequest,
SbomGenerationStatus.FAILED,
GenerationResult.ERR_GENERATION,
"Generation failed. One or more generated SBOMs failed validation: {}. See logs for more information.", e.getMessage());
"Generation failed. One or more generated SBOMs failed validation: {}. See logs for more information.",
e.getMessage());
}

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,11 @@ public void notifyCompleted(List<org.jboss.sbomer.service.feature.sbom.model.Sbo
* Skips sending UMB messages for manifests not related to a product build.
*/
if (ProductConfig.ErrataProductConfig.fromBom(bom) == null) {
throw new NotificationException(
log.warn(
"Could not retrieve product configuration from the main component (purl = '{}') in the '{}' SBOM, skipping sending UMB notification",
component.getPurl(),
sbom.getRootPurl(),
sbom.getId());
return;
}

// Check whether we should send UMB notification for a given type.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,13 +322,7 @@ void shouldSkipNotificationForNonProductBuilds() throws IOException {
// Remove all product properties
sbom.setSbom(SbomUtils.removeErrataProperties(sbom.getSbom()));

ApplicationException ex = assertThrows(ApplicationException.class, () -> {
notificationService.notifyCompleted(List.of(sbom));
});

assertEquals(
"Could not retrieve product configuration from the main component (purl = 'pkg:maven/com.github.michalszynkiewicz.test/[email protected]?type=jar') in the '416640206274228333' SBOM, skipping sending UMB notification",
ex.getMessage());
notificationService.notifyCompleted(List.of(sbom));

verify(amqpMessageProducer, times(0)).notify(any(GenerationFinishedMessageBody.class));
}
Expand Down

0 comments on commit 69325f2

Please sign in to comment.