diff --git a/src/main/java/org/prebid/server/auction/BidResponseCreator.java b/src/main/java/org/prebid/server/auction/BidResponseCreator.java index cbb63000c5c..0ae43405432 100644 --- a/src/main/java/org/prebid/server/auction/BidResponseCreator.java +++ b/src/main/java/org/prebid/server/auction/BidResponseCreator.java @@ -87,6 +87,7 @@ import org.prebid.server.proto.openrtb.ext.response.ExtDebugTrace; import org.prebid.server.proto.openrtb.ext.response.ExtHttpCall; import org.prebid.server.proto.openrtb.ext.response.ExtIgi; +import org.prebid.server.proto.openrtb.ext.response.ExtIgiIgb; import org.prebid.server.proto.openrtb.ext.response.ExtIgiIgs; import org.prebid.server.proto.openrtb.ext.response.ExtIgiIgsExt; import org.prebid.server.proto.openrtb.ext.response.ExtResponseCache; @@ -864,13 +865,18 @@ private ExtIgi prepareExtIgi(ExtIgi igi, String bidder) { return null; } - if (StringUtils.isEmpty(igi.getImpid())) { - conditionalLogger.warn("ExtIgi with absent impId", logSamplingRate); - return null; + boolean shouldDropIgb = StringUtils.isEmpty(igi.getImpid()); + if (shouldDropIgb) { + conditionalLogger.warn("ExtIgi with absent impId from bidder: " + bidder, logSamplingRate); } - final List preparedIgs = prepareExtIgiIgs(igi.getIgs(), bidder); - return igi.toBuilder().igs(preparedIgs.isEmpty() ? null : preparedIgs).build(); + final List updatedIgs = prepareExtIgiIgs(igi.getIgs(), bidder); + final List preparedIgs = updatedIgs.isEmpty() ? null : updatedIgs; + final List preparedIgb = shouldDropIgb ? null : igi.getIgb(); + + return ObjectUtils.anyNotNull(preparedIgs, preparedIgb) + ? igi.toBuilder().igs(preparedIgs).igb(preparedIgb).build() + : null; } private List prepareExtIgiIgs(List igiIgs, String bidder) { @@ -885,12 +891,12 @@ private List prepareExtIgiIgs(List igiIgs, String bidder) } if (StringUtils.isEmpty(extIgiIgs.getImpId())) { - conditionalLogger.warn("ExtIgiIgs with absent impId", logSamplingRate); + conditionalLogger.warn("ExtIgiIgs with absent impId from bidder: " + bidder, logSamplingRate); continue; } if (extIgiIgs.getConfig() == null) { - conditionalLogger.warn("ExtIgiIgs with absent config", logSamplingRate); + conditionalLogger.warn("ExtIgiIgs with absent config from bidder: " + bidder, logSamplingRate); continue; } diff --git a/src/test/java/org/prebid/server/auction/BidResponseCreatorTest.java b/src/test/java/org/prebid/server/auction/BidResponseCreatorTest.java index c3b19bcc491..0b6d4b67b9f 100644 --- a/src/test/java/org/prebid/server/auction/BidResponseCreatorTest.java +++ b/src/test/java/org/prebid/server/auction/BidResponseCreatorTest.java @@ -98,6 +98,7 @@ import org.prebid.server.proto.openrtb.ext.response.ExtDebugTrace; import org.prebid.server.proto.openrtb.ext.response.ExtHttpCall; import org.prebid.server.proto.openrtb.ext.response.ExtIgi; +import org.prebid.server.proto.openrtb.ext.response.ExtIgiIgb; import org.prebid.server.proto.openrtb.ext.response.ExtIgiIgs; import org.prebid.server.proto.openrtb.ext.response.ExtIgiIgsExt; import org.prebid.server.proto.openrtb.ext.response.ExtResponseCache; @@ -3744,14 +3745,16 @@ public void shouldDefaultToOriginalPaaFormat() { } @Test - public void shouldDropExtIgiIfAvailableAndExtIgiImpIdIsAbsent() { + public void shouldDropExtIgiIgbIfAvailableAndExtIgiImpIdIsAbsent() { // given + given(bidderCatalog.resolveBaseBidder("bidder1")).willReturn("adapter1"); final Imp imp = givenImp("impId").toBuilder() .ext(mapper.createObjectNode().put("ae", 1)) .build(); final BidRequest bidRequest = givenBidRequest(identity(), ext -> ext.paaFormat(PaaFormat.IAB), imp); final ExtIgi igi = ExtIgi.builder() .igs(singletonList(ExtIgiIgs.builder().impId("impId").config(mapper.createObjectNode()).build())) + .igb(singletonList(ExtIgiIgb.builder().build())) .build(); final Bid bid = Bid.builder().id("bidId1").price(BigDecimal.valueOf(2.37)).impid("impId").build(); @@ -3774,7 +3777,16 @@ public void shouldDropExtIgiIfAvailableAndExtIgiImpIdIsAbsent() { // then assertThat(bidResponse.getExt()) .extracting(ExtBidResponse::getIgi) - .isNull(); + .asList() + .containsExactly( + ExtIgi.builder() + .igs(singletonList( + ExtIgiIgs.builder() + .impId("impId") + .config(mapper.createObjectNode()) + .ext(ExtIgiIgsExt.of("bidder1", "adapter1")) + .build())) + .build()); } @Test @@ -3787,6 +3799,7 @@ public void shouldDropExtIgiIgsIfAvailableAndExtIgiIgsImpIdIsAbsent() { final ExtIgi igi = ExtIgi.builder() .impid("impId") .igs(singletonList(ExtIgiIgs.builder().config(mapper.createObjectNode()).build())) + .igb(singletonList(ExtIgiIgb.builder().build())) .build(); final Bid bid = Bid.builder().id("bidId1").price(BigDecimal.valueOf(2.37)).impid("impId").build(); @@ -3810,7 +3823,11 @@ public void shouldDropExtIgiIgsIfAvailableAndExtIgiIgsImpIdIsAbsent() { assertThat(bidResponse.getExt()) .extracting(ExtBidResponse::getIgi) .asList() - .containsExactly(ExtIgi.builder().impid("impId").build()); + .containsExactly( + ExtIgi.builder() + .impid("impId") + .igb(singletonList(ExtIgiIgb.builder().build())) + .build()); } @Test @@ -3823,6 +3840,7 @@ public void shouldDropExtIgiIgsIfAvailableAndExtIgiIgsConfigIsAbsent() { final ExtIgi igi = ExtIgi.builder() .impid("impId") .igs(singletonList(ExtIgiIgs.builder().impId("impId").build())) + .igb(singletonList(ExtIgiIgb.builder().build())) .build(); final Bid bid = Bid.builder().id("bidId1").price(BigDecimal.valueOf(2.37)).impid("impId").build(); @@ -3846,7 +3864,45 @@ public void shouldDropExtIgiIgsIfAvailableAndExtIgiIgsConfigIsAbsent() { assertThat(bidResponse.getExt()) .extracting(ExtBidResponse::getIgi) .asList() - .containsExactly(ExtIgi.builder().impid("impId").build()); + .containsExactly( + ExtIgi.builder() + .impid("impId") + .igb(singletonList(ExtIgiIgb.builder().build())) + .build()); + } + + @Test + public void shouldDropExtIgiIfAvailableAndExtIgiIgsAndExtIgiIgbAreAbsent() { + // given + final Imp imp = givenImp("impId").toBuilder() + .ext(mapper.createObjectNode().put("ae", 1)) + .build(); + final BidRequest bidRequest = givenBidRequest(identity(), ext -> ext.paaFormat(PaaFormat.IAB), imp); + final ExtIgi igi = ExtIgi.builder() + .impid("impId") + .build(); + + final Bid bid = Bid.builder().id("bidId1").price(BigDecimal.valueOf(2.37)).impid("impId").build(); + final List bidderResponses = singletonList( + BidderResponse.of("bidder1", + BidderSeatBid.builder() + .bids(List.of(BidderBid.of(bid, banner, "USD"))) + .igi(singletonList(igi)) + .build(), 100)); + + final AuctionContext auctionContext = givenAuctionContext( + bidRequest, + contextBuilder -> contextBuilder.auctionParticipations(toAuctionParticipant(bidderResponses))); + + // when + final BidResponse bidResponse = target + .create(auctionContext, CACHE_INFO, MULTI_BIDS) + .result(); + + // then + assertThat(bidResponse.getExt()) + .extracting(ExtBidResponse::getIgi) + .isNull(); } @Test