-
Notifications
You must be signed in to change notification settings - Fork 753
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
Adapter Name Case Insensitive: Stored Bid Responses #3197
Changes from 1 commit
c870c0b
421e54d
3bc4b76
3ecaeef
33187cc
3e2d920
d4fb8e0
1b53ce4
0a73798
01e1a85
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 |
---|---|---|
|
@@ -1525,7 +1525,7 @@ func (deps *endpointDeps) validateImpExt(imp *openrtb_ext.ImpWrapper, aliases ma | |
} | ||
|
||
if len(storedBidResp) > 0 { | ||
if err := validateStoredBidRespAndImpExtBidders(prebid.Bidder, storedBidResp, imp.ID); err != nil { | ||
if err := deps.validateStoredBidRespAndImpExtBidders(prebid.Bidder, storedBidResp, imp.ID); err != nil { | ||
return []error{err} | ||
} | ||
} | ||
|
@@ -2492,19 +2492,18 @@ func checkIfAppRequest(request []byte) (bool, error) { | |
return false, nil | ||
} | ||
|
||
func validateStoredBidRespAndImpExtBidders(bidderExts map[string]json.RawMessage, storedBidResp stored_responses.ImpBidderStoredResp, impId string) error { | ||
func (deps *endpointDeps) validateStoredBidRespAndImpExtBidders(bidderExts map[string]json.RawMessage, storedBidResp stored_responses.ImpBidderStoredResp, impId string) error { | ||
if bidResponses, ok := storedBidResp[impId]; ok { | ||
if len(bidResponses) != len(bidderExts) { | ||
return generateStoredBidResponseValidationError(impId) | ||
} | ||
|
||
for bidderName := range bidResponses { | ||
bidder := bidderName | ||
normalizedCoreBidder, ok := openrtb_ext.NormalizeBidderName(bidder) | ||
if ok { | ||
bidder = normalizedCoreBidder.String() | ||
_, bidderNameOk := deps.normalizeBidderName(bidderName) | ||
if !bidderNameOk { | ||
return fmt.Errorf(`unrecognized bidder "%v"`, bidderName) | ||
} | ||
if _, present := bidderExts[bidder]; !present { | ||
if _, present := bidderExts[bidderName]; !present { | ||
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. Mostly for my education. Why are we not using normalised bidder name to lookup on 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. I added a description with explanations how it works. We need to use bidder name as it is specified in imp, not normalized bidder name. 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. |
||
return generateStoredBidResponseValidationError(impId) | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{ | ||
"description": "request with impression with stored bid response with case matching bidder name", | ||
"mockBidRequest": { | ||
"id": "request-with-stored-resp", | ||
"site": { | ||
"page": "test.somepage.com" | ||
}, | ||
"imp": [ | ||
{ | ||
"id": "imp-id3", | ||
"banner": { | ||
"format": [ | ||
{ | ||
"w": 300, | ||
"h": 600 | ||
} | ||
] | ||
}, | ||
"ext": { | ||
"appnexus": { | ||
"placementId": 12883451 | ||
}, | ||
"prebid": { | ||
"storedbidresponse": [ | ||
{ | ||
"bidder": "appnexus", | ||
"id": "bidResponseId3" | ||
} | ||
] | ||
} | ||
} | ||
} | ||
], | ||
"user": { | ||
"yob": 1989 | ||
} | ||
}, | ||
"expectedReturnCode": 200 | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"description": "request with impression with stored bid response with sensitive bidder name", | ||
"description": "request with impression with stored bid response with case matching bidder name", | ||
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. Nitpick: Typo "case not matching" |
||
"mockBidRequest": { | ||
"id": "request-with-stored-resp", | ||
"site": { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
"description": "request with impression with stored bid response", | ||
"mockBidRequest": { | ||
"id": "request-with-stored-resp", | ||
"site": { | ||
"page": "test.somepage.com" | ||
}, | ||
"imp": [ | ||
{ | ||
"id": "imp-id1", | ||
"banner": { | ||
"format": [ | ||
{ | ||
"w": 300, | ||
"h": 600 | ||
} | ||
] | ||
}, | ||
"ext": { | ||
"bidderABC": {}, | ||
"prebid": { | ||
"storedbidresponse": [ | ||
{"bidder":"bidderABC", "id": "bidResponseId1"} | ||
] | ||
} | ||
} | ||
} | ||
], | ||
"user": { | ||
"yob": 1989 | ||
} | ||
}, | ||
"expectedReturnCode": 200 | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -97,17 +97,6 @@ func extractStoredResponsesIds(impInfo []ImpExtPrebidData, | |
if len(bidderResp.ID) == 0 || len(bidderResp.Bidder) == 0 { | ||
return nil, nil, nil, nil, fmt.Errorf("request.imp[%d] has ext.prebid.storedbidresponse specified, but \"id\" or/and \"bidder\" fields are missing ", index) | ||
} | ||
bidderName := bidderResp.Bidder | ||
normalizedCoreBidder, ok := openrtb_ext.NormalizeBidderName(bidderResp.Bidder) | ||
if ok { | ||
bidderName = normalizedCoreBidder.String() | ||
} | ||
//check if bidder is valid/exists | ||
if _, isValid := bidderMap[bidderName]; !isValid { | ||
return nil, nil, nil, nil, fmt.Errorf("request.imp[impId: %s].ext.prebid.bidder contains unknown bidder: %s. Did you forget an alias in request.ext.prebid.aliases?", impId, bidderResp.Bidder) | ||
} | ||
Comment on lines
-106
to
-109
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. I see that this logic was removed. Isn't this logic checking that the stored response bidder name is the name of a bidder defined in the imp? Do we need this? Does this error detection exist elsewhere? 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. Yes, this function is only about parsing request. This check is now in if _, bidderNameOk := deps.normalizeBidderName(bidderName); !bidderNameOk {
return fmt.Errorf(`unrecognized bidder "%v"`, bidderName)
} |
||
// bidder is unique per one bid stored response | ||
// if more than one bidder specified the last defined bidder id will take precedence | ||
bidderStoredRespId[bidderResp.Bidder] = bidderResp.ID | ||
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. Mostly for my education. Why was the code block from line 100 to 110 removed? 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. This was a fail-fast logic, that is not needed in |
||
impBiddersWithBidResponseIDs[impId] = bidderStoredRespId | ||
|
||
|
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.
Nitpick:
bidderNameOk
is only used in theif
statement. Can we merge the two lines?