Skip to content

Commit 31d3a39

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 31d3a39

2 files changed

Lines changed: 44 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: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,46 @@ public void makeHttpRequestsShouldAddPlacementIdOnlyInFirstImpressionTagId() {
9595
.containsExactly("pid", null);
9696
}
9797

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

0 commit comments

Comments
 (0)