PS bid caching failures - #943
Conversation
| cache.bids = Bids.fromJSONObject(jsonObject.optJSONObject("bids")); | ||
| cache.vastXml = Bids.fromJSONObject(jsonObject.optJSONObject("vastXml")); | ||
| if (!cache.vastXml.hasCacheData()) { | ||
| cache.vastXml = Bids.fromJSONObject(jsonObject.optJSONObject("vastxml")); |
There was a problem hiding this comment.
Is it possible that the variable will be in different cases: vastXml and vastxml?
There was a problem hiding this comment.
According to the PBS docs, the request extension is ext.prebid.cache.vastxml, while the response extension is seatbid.bid.ext.prebid.cache.vastXml. Since this parser handles responses, only vastXml field is needed. I kept vastxml as a compatibility fallback, but updated the implementation to select the non-null JSON object first and parse once.
| cache.url = jsonObject.optString("url"); | ||
| cache.bids = Bids.fromJSONObject(jsonObject.optJSONObject("bids")); | ||
| cache.vastXml = Bids.fromJSONObject(jsonObject.optJSONObject("vastXml")); | ||
| if (!cache.vastXml.hasCacheData()) { |
There was a problem hiding this comment.
It will be more readable and faster, if we first call optJSONObject to find a non-nullable VAST XML object, then call hasCacheData .
| } | ||
| } | ||
|
|
||
| seatbids = filteredSeatbids; |
There was a problem hiding this comment.
The implementation looks correct, but recreating the bids list can be time-consuming. Maybe it'll be simpler to move this logic to the parseJson method and do not add non-cached bids. Or do we have some limitations?
54281ec to
b8e0080
Compare
#1258