Skip to content
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

Make user.ext.prebid.buyeruids bidder name case insensitive #3152

Merged
merged 10 commits into from
Oct 17, 2023
Merged
3 changes: 3 additions & 0 deletions endpoints/openrtb2/amp_auction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ func TestGoodAmpRequests(t *testing.T) {
"imp-with-stored-resp.json",
"gdpr-no-consentstring.json",
"gdpr.json",
"buyeruids-case-insensitive.json",
"buyeruids-camel-case.json",
"aliased-buyeruids-case-insensitive.json",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that you have two test case files that you added for this PR. Would it mean that it also needs to be added in this function?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! Added it in 07427d6

},
},
{
Expand Down
4 changes: 3 additions & 1 deletion endpoints/openrtb2/auction.go
Original file line number Diff line number Diff line change
Expand Up @@ -1816,7 +1816,9 @@ func (deps *endpointDeps) validateUser(req *openrtb_ext.RequestWrapper, aliases
return append(errL, errors.New(`request.user.ext.prebid requires a "buyeruids" property with at least one ID defined. If none exist, then request.user.ext.prebid should not be defined.`))
}
for bidderName := range prebid.BuyerUIDs {
if _, ok := deps.bidderMap[bidderName]; !ok {
normalizedCoreBidder, _ := openrtb_ext.NormalizeBidderName(bidderName)
coreBidder := normalizedCoreBidder.String()
if _, ok := deps.bidderMap[coreBidder]; !ok {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: in this PR here https://github.com/prebid/prebid-server/pull/3187/files#diff-785f5ab5ebde657757f3b3c34bf30a939782678d61bf1ea43f844c4f22a012d9R155:~:text=normalizeBidderName%20%20%20%20%20%20%20normalizeBidderName @SyntaxNode introduced a new function in endpoint deps.
This validation function already has deps. Could you please pull latest changes from main branch and call normalize bidder name through the normalizedCoreBidder, _ := deps.normalizeBidderName(bidderName). With this change code will be more consistent.

Other than this looks good, local testing looks good too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, Veronika! Updated it in 49a8d0e

if _, ok := aliases[bidderName]; !ok {
return append(errL, fmt.Errorf("request.user.ext.%s is neither a known bidder name nor an alias in request.ext.prebid.aliases", bidderName))
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
{
"description": "Amp request where root.user.ext.prebid.buyeruids field makes use of alias defined in root.ext.prebid.aliases and request makes use of case sensitive bidder name",
"query": "tag_id=101",
"config": {
"mockBidders": [
{
"bidderName": "appnexus",
"currency": "USD",
"price": 2
}
]
},
"mockBidRequest": {
"id": "request-with-user-ext-obj",
"site": {
"page": "test.somepage.com"
},
"imp": [
{
"id": "my-imp-id",
"banner": {
"format": [
{
"w": 300,
"h": 600
}
]
},
"ext": {
"prebid": {
"bidder": {
"Appnexus": {
"placementId": 12883451
}
}
}
}
}
],
"user": {
"ext": {
"prebid": {
"buyeruids": {
"unknown": "123"
}
}
}
},
"ext": {
"prebid": {
"aliases": {
"unknown": "Appnexus"
}
}
}
},
"expectedAmpResponse": {
"targeting": {
"hb_bidder": "Appnexus",
"hb_bidder_Appnexus": "Appnexus",
"hb_cache_host": "www.pbcserver.com",
"hb_cache_host_Appnex": "www.pbcserver.com",
"hb_cache_id": "0",
"hb_cache_id_Appnexus": "0",
"hb_cache_path": "/pbcache/endpoint",
"hb_cache_path_Appnex": "/pbcache/endpoint",
"hb_pb": "2.00",
"hb_pb_Appnexus": "2.00"
},
"ortb2": {
"ext": {
"warnings": {
"general": [
{
"code": 10002,
"message": "debug turned off for account"
}
]
}
}
}
},
"expectedReturnCode": 200
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{
"description": "Amp request where root.user.ext.prebid.buyeruids field has camel case bidder name",
"query": "tag_id=101",
"config": {
"mockBidders": [
{
"bidderName": "yahooAds",
"currency": "USD",
"price": 2
}
]
},
"mockBidRequest": {
"id": "request-with-user-ext-obj",
"site": {
"page": "test.somepage.com"
},
"imp": [
{
"id": "my-imp-id",
"banner": {
"format": [
{
"w": 300,
"h": 600
}
]
},
"ext": {
"prebid": {
"bidder": {
"YahooAds": {
"placementId": 12883451
}
}
}
}
}
],
"user": {
"ext": {
"prebid": {
"buyeruids": {
"YahooAds": "123"
}
}
}
}
},
"expectedAmpResponse": {
"targeting": {
"hb_bidder": "YahooAds",
"hb_bidder_YahooAds": "YahooAds",
"hb_cache_host": "www.pbcserver.com",
"hb_cache_host_YahooA": "www.pbcserver.com",
"hb_cache_id": "0",
"hb_cache_id_YahooAds": "0",
"hb_cache_path": "/pbcache/endpoint",
"hb_cache_path_YahooA": "/pbcache/endpoint",
"hb_pb": "2.00",
"hb_pb_YahooAds": "2.00"
},
"ortb2": {
"ext": {
"warnings": {
"general": [
{
"code": 10002,
"message": "debug turned off for account"
}
]
}
}
}
},
"expectedReturnCode": 200
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{
"description": "Amp request where root.user.ext.prebid.buyeruids field has case insensitive bidder name",
"query": "tag_id=101",
"config": {
"mockBidders": [
{
"bidderName": "appnexus",
"currency": "USD",
"price": 2
}
]
},
"mockBidRequest": {
"id": "request-with-user-ext-obj",
"site": {
"page": "test.somepage.com"
},
"imp": [
{
"id": "my-imp-id",
"banner": {
"format": [
{
"w": 300,
"h": 600
}
]
},
"ext": {
"prebid": {
"bidder": {
"Appnexus": {
"placementId": 12883451
}
}
}
}
}
],
"user": {
"ext": {
"prebid": {
"buyeruids": {
"Appnexus": "123"
}
}
}
}
},
"expectedAmpResponse": {
"targeting": {
"hb_bidder": "Appnexus",
"hb_bidder_Appnexus": "Appnexus",
"hb_cache_host": "www.pbcserver.com",
"hb_cache_host_Appnex": "www.pbcserver.com",
"hb_cache_id": "0",
"hb_cache_id_Appnexus": "0",
"hb_cache_path": "/pbcache/endpoint",
"hb_cache_path_Appnex": "/pbcache/endpoint",
"hb_pb": "2.00",
"hb_pb_Appnexus": "2.00"
},
"ortb2": {
"ext": {
"warnings": {
"general": [
{
"code": 10002,
"message": "debug turned off for account"
}
]
}
}
}
},
"expectedReturnCode": 200
}