-
Notifications
You must be signed in to change notification settings - Fork 748
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rubicon: Fix Nil Reference Panic From #1909 #1918
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 { | ||
|
@@ -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 | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The test case for an empty or missing data array looked odd, because the |
||
|
||
extRPTarget := make(map[string]interface{}) | ||
|
||
|
@@ -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)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Minor memory optimization. |
||
|
||
for _, dataRecord := range data { | ||
if dataRecord.Ext != nil { | ||
|
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" | ||
} | ||
] | ||
} | ||
] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to verify
siteCopy.Content
is notnil
before referencingsiteCopy.Content.Data
.