Skip to content

Commit 79604dd

Browse files
Mobkoi: Always set the TagID with our placementID
We have a discrepancy between our Prebid Server and our Tag/PrebidJS integration. It’s not replacing the `bidrequest.Imp[0].TagID` with our internal value when a TagID is already present. We are able to deliver because the value is set in the `bidrequest.Imp[0].Ext.placementID` field, but this creates discrepancies between the connectors, and it’s not ideal.
1 parent 033af31 commit 79604dd

2 files changed

Lines changed: 36 additions & 4 deletions

File tree

src/main/java/org/prebid/server/bidder/mobkoi/MobkoiBidder.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,14 @@ private ExtImpMobkoi parseExtImp(Imp imp) {
7575
}
7676

7777
private Imp modifyImp(Imp firstImp, ExtImpMobkoi extImpMobkoi) {
78-
if (StringUtils.isNotBlank(firstImp.getTagid())) {
79-
return firstImp;
80-
}
81-
8278
if (StringUtils.isNotBlank(extImpMobkoi.getPlacementId())) {
8379
return firstImp.toBuilder().tagid(extImpMobkoi.getPlacementId()).build();
8480
}
8581

82+
if (StringUtils.isNotBlank(firstImp.getTagid())) {
83+
return firstImp;
84+
}
85+
8686
throw new PreBidException("invalid because it comes with neither request.imp[0].tagId nor "
8787
+ "req.imp[0].ext.Bidder.placementId");
8888
}

src/test/java/org/prebid/server/bidder/mobkoi/MobkoiBidderTest.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,38 @@ public void makeHttpRequestsShouldAddPlacementIdOnlyInFirstImpressionTagId() {
9595
.containsExactly("pid", null);
9696
}
9797

98+
@Test
99+
public void makeHttpRequestsShouldOverrideExistingTagIdWithPlacementId() {
100+
final ObjectNode mobkoiExt = impExt("placement-id-from-ext");
101+
final Imp givenImp1 = givenImp(impBuilder -> impBuilder.tagid("existing-tag-id").ext(mobkoiExt));
102+
final Imp givenImp2 = givenImp(identity());
103+
final BidRequest bidRequest = BidRequest.builder().imp(asList(givenImp1, givenImp2)).build();
104+
final Result<List<HttpRequest<BidRequest>>> result = target.makeHttpRequests(bidRequest);
105+
106+
assertThat(result.getValue())
107+
.extracting(httpRequest -> mapper.readValue(httpRequest.getBody(), BidRequest.class))
108+
.flatExtracting(BidRequest::getImp)
109+
.extracting(imp -> imp.getTagid())
110+
.containsExactly("placement-id-from-ext", null);
111+
assertThat(result.getErrors()).isEmpty();
112+
}
113+
114+
@Test
115+
public void makeHttpRequestsShouldKeepExistingTagIdWhenPlacementIdIsMissing() {
116+
final ObjectNode mobkoiExt = impExt(null);
117+
final Imp givenImp1 = givenImp(impBuilder -> impBuilder.tagid("existing-tag-id").ext(mobkoiExt));
118+
final Imp givenImp2 = givenImp(identity());
119+
final BidRequest bidRequest = BidRequest.builder().imp(asList(givenImp1, givenImp2)).build();
120+
final Result<List<HttpRequest<BidRequest>>> result = target.makeHttpRequests(bidRequest);
121+
122+
assertThat(result.getValue())
123+
.extracting(httpRequest -> mapper.readValue(httpRequest.getBody(), BidRequest.class))
124+
.flatExtracting(BidRequest::getImp)
125+
.extracting(imp -> imp.getTagid())
126+
.containsExactly("existing-tag-id", null);
127+
assertThat(result.getErrors()).isEmpty();
128+
}
129+
98130
@Test
99131
public void makeHttpRequestsShouldOverrideUserExtAndSetConsent() {
100132
// given

0 commit comments

Comments
 (0)