Skip to content

Commit

Permalink
Added logic to ensure that the first stored response is used instead …
Browse files Browse the repository at this point in the history
…of the last if there are multiple stored responses for the same bidder
  • Loading branch information
VeronikaSolovei9 committed Oct 17, 2023
1 parent 3bc4b76 commit 3ecaeef
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
2 changes: 1 addition & 1 deletion stored_responses/stored_responses.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func extractStoredResponsesIds(impInfo []*openrtb_ext.ImpWrapper) (
}

for _, bidderName := range allBidderNames {
if strings.EqualFold(bidderName, bidderResp.Bidder) {
if _, found := bidderStoredRespId[bidderName]; !found && strings.EqualFold(bidderName, bidderResp.Bidder) {
bidderStoredRespId[bidderName] = bidderResp.ID
impBiddersWithBidResponseIDs[impId] = bidderStoredRespId

Expand Down
37 changes: 37 additions & 0 deletions stored_responses/stored_responses_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,43 @@ func TestProcessStoredAuctionAndBidResponses(t *testing.T) {
"BiddeRa": map[string]bool{"imp-id1": true},
},
},
{
description: "Stored bid responses 3 same mixed case bidders in imp.ext and imp.ext.prebid.bidders one imp, duplicated stored response",
request: openrtb2.BidRequest{
Imp: []openrtb2.Imp{
{ID: "imp-id1",
Ext: json.RawMessage(`{
"bidderA": {
"placementId": 123
},
"BIDDERa": {
"placementId": 123
},
"prebid": {
"bidder": {
"BiddeRa": {
"placementId": 12883451
}
},
"storedbidresponse": [
{"bidder":"bidderA", "id": "1", "replaceimpid": true},
{"bidder":"bidderA", "id": "2", "replaceimpid": true},
{"bidder":"bidderB", "id": "2", "replaceimpid": false}
]
}
}`)},
},
},
expectedStoredAuctionResponses: ImpsWithBidResponses{},
expectedStoredBidResponses: ImpBidderStoredResp{
"imp-id1": {"bidderA": bidStoredResp1, "BIDDERa": bidStoredResp1, "BiddeRa": bidStoredResp1},
},
expectedBidderImpReplaceImpID: BidderImpReplaceImpID{
"BIDDERa": map[string]bool{"imp-id1": true},
"bidderA": map[string]bool{"imp-id1": true},
"BiddeRa": map[string]bool{"imp-id1": true},
},
},
{
//This is not a valid scenario for real auction request, added for testing purposes
description: "Stored auction and bid responses one imp",
Expand Down

0 comments on commit 3ecaeef

Please sign in to comment.