Hi,
I think I have found a bug in the current version of PBS, albeit an edge case. I have patched it, but I am sure the team has a more elegant solution than mine.
The problem occurs when using both stored impressions and a stored request. Then stored impressions are looked up using an object map that is populated before the stored impression is applied. Once the stored impression is merged the lookup fails, because the impression objects are now different.
The issue occurs in this function.
And this is my (far from elegant) fix:
private BidRequest mergeImps(BidRequest bidRequest,
Map<Imp, String> impToStoredId,
StoredDataResult storedDataResult) {
if (impToStoredId.isEmpty()) {
return bidRequest;
}
final List<Imp> mergedImps = new ArrayList<>(bidRequest.getImp());
for (int i = 0; i < mergedImps.size(); i++) {
final Imp imp = mergedImps.get(i);
final String storedRequestId = getStoredRequestId(imp);
if (storedRequestId != null) {
final String storedImp = storedDataResult.getStoredIdToImp().get(storedRequestId);
final Imp mergedImp = jsonMerger.merge(imp, storedImp, storedRequestId, Imp.class);
mergedImps.set(i, mergedImp);
}
}
return bidRequest.toBuilder().imp(mergedImps).build();
}
private static String getStoredRequestId(Imp imp) {
final ObjectNode extImp = imp.getExt();
String storedRequestId = null;
if (extImp != null) {
final JsonNode prebid = extImp.get("prebid");
if (prebid != null) {
final JsonNode storedrequest = prebid.get("storedrequest");
if (storedrequest != null) {
final JsonNode id = storedrequest.get("id");
if (id != null) {
storedRequestId = id.asText();
}
}
}
}
return storedRequestId;
}
The specific use case where I came across this was when trying to augment the list of passed in bidders with additional bidders from a stored impression. This was working fine when a stored request was not present, but stopped working with a stored request present.
Thanks for taking a look.
Olly.
Hi,
I think I have found a bug in the current version of PBS, albeit an edge case. I have patched it, but I am sure the team has a more elegant solution than mine.
The problem occurs when using both stored impressions and a stored request. Then stored impressions are looked up using an object map that is populated before the stored impression is applied. Once the stored impression is merged the lookup fails, because the impression objects are now different.
The issue occurs in this function.
And this is my (far from elegant) fix:
The specific use case where I came across this was when trying to augment the list of passed in bidders with additional bidders from a stored impression. This was working fine when a stored request was not present, but stopped working with a stored request present.
Thanks for taking a look.
Olly.