Skip to content

Commit

Permalink
Rubicon: Fix Nil Reference Panic (#1918)
Browse files Browse the repository at this point in the history
  • Loading branch information
SyntaxNode authored Jul 9, 2021
1 parent e7f7b55 commit e87bec4
Show file tree
Hide file tree
Showing 3 changed files with 593 additions and 6 deletions.
17 changes: 11 additions & 6 deletions adapters/rubicon/rubicon.go
Original file line number Diff line number Diff line change
Expand Up @@ -852,12 +852,14 @@ func (a *RubiconAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *ada
if request.Site != nil {
siteCopy := *request.Site
siteExtRP := rubiconSiteExt{RP: rubiconSiteExtRP{SiteID: rubiconExt.SiteId}}
target, err := updateExtWithIabAttribute(nil, siteCopy.Content.Data, []int{1, 2})
if err != nil {
errs = append(errs, err)
continue
if siteCopy.Content != nil {
target, err := updateExtWithIabAttribute(nil, siteCopy.Content.Data, []int{1, 2})
if err != nil {
errs = append(errs, err)
continue
}
siteExtRP.RP.Target = target
}
siteExtRP.RP.Target = target

siteCopy.Ext, err = json.Marshal(&siteExtRP)
if err != nil {
Expand Down Expand Up @@ -919,6 +921,9 @@ func resolveBidFloorAttributes(bidFloor float64, bidFloorCur string) (float64, s

func updateExtWithIabAttribute(target json.RawMessage, data []openrtb2.Data, segTaxes []int) (json.RawMessage, error) {
var segmentIdsToCopy = getSegmentIdsToCopy(data, segTaxes)
if len(segmentIdsToCopy) == 0 {
return target, nil
}

extRPTarget := make(map[string]interface{})

Expand All @@ -938,7 +943,7 @@ func updateExtWithIabAttribute(target json.RawMessage, data []openrtb2.Data, seg
}

func getSegmentIdsToCopy(data []openrtb2.Data, segTaxValues []int) []string {
var segmentIdsToCopy = make([]string, 0)
var segmentIdsToCopy = make([]string, 0, len(data))

for _, dataRecord := range data {
if dataRecord.Ext != nil {
Expand Down
293 changes: 293 additions & 0 deletions adapters/rubicon/rubicontest/supplemental/no-site-content-data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,293 @@
{
"mockBidRequest": {
"id": "test-request-id",
"device": {
"ip": "123.123.123.123",
"ifa": "zxcjbzxmc-zxcbmz-zxbcz-zxczx"
},
"app": {
"id": "1",
"bundle": "com.wls.testwlsapplication"
},
"site": {
"content": {
}
},
"user": {
"data": [
{
"ext": {
"segtax": 4
},
"segment": [
{
"id": "idToCopy"
}
]
},
{
"ext": {
"segtax": "someValue"
},
"segment": [
{
"id": "shouldNotBeCopied"
}
]
},
{
"ext": {
"segtax": "4"
},
"segment": [
{
"id": "shouldNotBeCopied2"
}
]
},
{
"ext": {
"segtax": 4
},
"segment": [
{
"id": "idToCopy2"
}
]
},
{
"ext": {
"segtax": [
4
]
},
"segment": [
{
"id": "shouldNotBeCopied3"
}
]
}
]
},
"imp": [
{
"id": "test-imp-id",
"instl": 1,
"video": {
"placement": 3,
"mimes": [
"video/mp4"
],
"protocols": [
2,
5
],
"w": 1024,
"h": 576
},
"bidfloor": 1,
"bidfloorcur": "EuR",
"ext": {
"bidder": {
"video": {
},
"accountId": 1001,
"siteId": 113932,
"zoneId": 535510
}
}
}
]
},
"httpCalls": [
{
"expectedRequest": {
"uri": "uri?tk_xint=pbs-test-tracker",
"body": {
"id": "test-request-id",
"device": {
"ext": {
"rp": {
"pixelratio": 0
}
},
"ip": "123.123.123.123",
"ifa": "zxcjbzxmc-zxcbmz-zxbcz-zxczx"
},
"site": {
"content": {
},
"ext": {
"rp": {
"site_id": 113932
}
},
"publisher": {
"ext": {
"rp": {
"account_id": 1001
}
}
}
},
"user": {
"data": [
{
"ext": {
"segtax": 4
},
"segment": [
{
"id": "idToCopy"
}
]
},
{
"ext": {
"segtax": "someValue"
},
"segment": [
{
"id": "shouldNotBeCopied"
}
]
},
{
"ext": {
"segtax": "4"
},
"segment": [
{
"id": "shouldNotBeCopied2"
}
]
},
{
"ext": {
"segtax": 4
},
"segment": [
{
"id": "idToCopy2"
}
]
},
{
"ext": {
"segtax": [
4
]
},
"segment": [
{
"id": "shouldNotBeCopied3"
}
]
}
],
"ext": {
"rp": {
"target": {
"iab": [
"idToCopy",
"idToCopy2"
]
}
}
}
},
"app": {
"id": "1",
"bundle": "com.wls.testwlsapplication"
},
"imp": [
{
"id": "test-imp-id",
"instl": 1,
"video": {
"placement": 3,
"ext": {
"rp": {
"size_id": 203
}
},
"mimes": [
"video/mp4"
],
"protocols": [
2,
5
],
"w": 1024,
"h": 576
},
"bidfloor": 1.2,
"bidfloorcur": "USD",
"ext": {
"rp": {
"track": {
"mint": "",
"mint_version": ""
},
"zone_id": 535510
}
}
}
]
}
},
"mockResponse": {
"status": 200,
"body": {
"id": "test-request-id",
"seatbid": [
{
"bid": [
{
"id": "test_bid_id",
"impid": "test-imp-id",
"price": 0.27543,
"adm": "some-test-ad",
"cid": "test_cid",
"crid": "test_crid",
"dealid": "test_dealid",
"ext": {
"prebid": {
"type": "video"
}
}
}
],
"seat": "adman"
}
],
"cur": "USD"
}
}
}
],
"expectedBidResponses": [
{
"currency": "USD",
"bids": [
{
"bid": {
"id": "test_bid_id",
"impid": "test-imp-id",
"price": 0.27543,
"adm": "some-test-ad",
"cid": "test_cid",
"crid": "test_crid",
"dealid": "test_dealid",
"ext": {
"prebid": {
"type": "video"
}
}
},
"type": "video"
}
]
}
]
}
Loading

0 comments on commit e87bec4

Please sign in to comment.