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

Fix: Use request alias as adaptercode #3587

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions exchange/bidder.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,14 +379,20 @@ func (bidder *bidderAdapter) requestBid(ctx context.Context, bidderRequest Bidde
}
}

alternateBidderCode := ""
if !strings.EqualFold(bidderRequest.BidderName.String(), bidderName.String()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a test in place where bidderRequest.BidderName is different from bidderName.string

I can't seem to find it, but just want to ensure we're testing the main case of this PR that you laid out.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In case of aliase bidder its possible to have bidderRequest.BidderName is different that bidderName.
For example groupm is alias/alternate bidder code of pubmatic. So in this case bidderRequest.BidderName will be pubmatic and bidderName will be groupm. We are expecting adaptercode as pubmatic.

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, is it possible to add a json test of some kind where we can have this situation covered?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@AlexBVolcy Added json test file alternate-bidder-codes-aliase.json

alternateBidderCode = bidderRequest.BidderName.String()
}

seatBidMap[bidderName].Bids = append(seatBidMap[bidderName].Bids, &entities.PbsOrtbBid{
Bid: bidResponse.Bids[i].Bid,
BidMeta: bidResponse.Bids[i].BidMeta,
BidType: bidResponse.Bids[i].BidType,
BidVideo: bidResponse.Bids[i].BidVideo,
DealPriority: bidResponse.Bids[i].DealPriority,
OriginalBidCPM: originalBidCpm,
OriginalBidCur: bidResponse.Currency,
Bid: bidResponse.Bids[i].Bid,
BidMeta: bidResponse.Bids[i].BidMeta,
BidType: bidResponse.Bids[i].BidType,
BidVideo: bidResponse.Bids[i].BidVideo,
DealPriority: bidResponse.Bids[i].DealPriority,
OriginalBidCPM: originalBidCpm,
OriginalBidCur: bidResponse.Currency,
AlternateBidderCode: alternateBidderCode,
})
seatBidMap[bidderName].Currency = currencyAfterAdjustments
}
Expand Down
45 changes: 25 additions & 20 deletions exchange/bidder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2518,10 +2518,11 @@ func TestExtraBid(t *testing.T) {
{
HttpCalls: []*openrtb_ext.ExtHttpCall{},
Bids: []*entities.PbsOrtbBid{{
Bid: &openrtb2.Bid{ID: "groupmImp1"},
DealPriority: 5,
BidType: openrtb_ext.BidTypeVideo,
OriginalBidCur: "USD",
Bid: &openrtb2.Bid{ID: "groupmImp1"},
DealPriority: 5,
BidType: openrtb_ext.BidTypeVideo,
OriginalBidCur: "USD",
AlternateBidderCode: "pubmatic",
}},
Seat: "groupm",
Currency: "USD",
Expand Down Expand Up @@ -2626,10 +2627,11 @@ func TestExtraBidWithAlternateBidderCodeDisabled(t *testing.T) {
{
HttpCalls: []*openrtb_ext.ExtHttpCall{},
Bids: []*entities.PbsOrtbBid{{
Bid: &openrtb2.Bid{ID: "groupmImp2"},
DealPriority: 5,
BidType: openrtb_ext.BidTypeVideo,
OriginalBidCur: "USD",
Bid: &openrtb2.Bid{ID: "groupmImp2"},
DealPriority: 5,
BidType: openrtb_ext.BidTypeVideo,
OriginalBidCur: "USD",
AlternateBidderCode: "pubmatic",
}},
Seat: "groupm-allowed",
Currency: "USD",
Expand Down Expand Up @@ -2734,10 +2736,11 @@ func TestExtraBidWithBidAdjustments(t *testing.T) {
ID: "groupmImp1",
Price: 21,
},
DealPriority: 5,
BidType: openrtb_ext.BidTypeVideo,
OriginalBidCPM: 7,
OriginalBidCur: "USD",
DealPriority: 5,
BidType: openrtb_ext.BidTypeVideo,
OriginalBidCPM: 7,
OriginalBidCur: "USD",
AlternateBidderCode: "PUBMATIC",
}},
Seat: "groupm",
Currency: "USD",
Expand Down Expand Up @@ -2847,10 +2850,11 @@ func TestExtraBidWithBidAdjustmentsUsingAdapterCode(t *testing.T) {
ID: "groupmImp1",
Price: 14,
},
DealPriority: 5,
BidType: openrtb_ext.BidTypeVideo,
OriginalBidCPM: 7,
OriginalBidCur: "USD",
DealPriority: 5,
BidType: openrtb_ext.BidTypeVideo,
OriginalBidCPM: 7,
OriginalBidCur: "USD",
AlternateBidderCode: "pubmatic",
}},
Seat: "groupm",
Currency: "USD",
Expand Down Expand Up @@ -2959,10 +2963,11 @@ func TestExtraBidWithMultiCurrencies(t *testing.T) {
ID: "groupmImp1",
Price: 571.5994430039375,
},
DealPriority: 5,
BidType: openrtb_ext.BidTypeVideo,
OriginalBidCPM: 7,
OriginalBidCur: "USD",
DealPriority: 5,
BidType: openrtb_ext.BidTypeVideo,
OriginalBidCPM: 7,
OriginalBidCur: "USD",
AlternateBidderCode: "pubmatic",
}},
Seat: "groupm",
Currency: "INR",
Expand Down
27 changes: 14 additions & 13 deletions exchange/entities/entities.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,18 @@ type PbsOrtbSeatBid struct {
// PbsOrtbBid.DealTierSatisfied is set to true by exchange.updateHbPbCatDur if deal tier satisfied otherwise it will be set to false
// PbsOrtbBid.GeneratedBidID is unique Bid id generated by prebid server if generate Bid id option is enabled in config
type PbsOrtbBid struct {
Bid *openrtb2.Bid
BidMeta *openrtb_ext.ExtBidPrebidMeta
BidType openrtb_ext.BidType
BidTargets map[string]string
BidVideo *openrtb_ext.ExtBidPrebidVideo
BidEvents *openrtb_ext.ExtBidPrebidEvents
BidFloors *openrtb_ext.ExtBidPrebidFloors
DealPriority int
DealTierSatisfied bool
GeneratedBidID string
OriginalBidCPM float64
OriginalBidCur string
TargetBidderCode string
Bid *openrtb2.Bid
BidMeta *openrtb_ext.ExtBidPrebidMeta
BidType openrtb_ext.BidType
BidTargets map[string]string
BidVideo *openrtb_ext.ExtBidPrebidVideo
BidEvents *openrtb_ext.ExtBidPrebidEvents
BidFloors *openrtb_ext.ExtBidPrebidFloors
DealPriority int
DealTierSatisfied bool
GeneratedBidID string
OriginalBidCPM float64
OriginalBidCur string
TargetBidderCode string
AlternateBidderCode string
}
7 changes: 6 additions & 1 deletion exchange/exchange.go
Original file line number Diff line number Diff line change
Expand Up @@ -1299,7 +1299,12 @@ func (e *exchange) makeBid(bids []*entities.PbsOrtbBid, auc *auction, returnCrea
}
}

if bidExtJSON, err := makeBidExtJSON(bid.Bid.Ext, bidExtPrebid, impExtInfoMap, bid.Bid.ImpID, bid.OriginalBidCPM, bid.OriginalBidCur, adapter); err != nil {
adapterCode := adapter
if bid.AlternateBidderCode != "" {
adapterCode = openrtb_ext.BidderName(bid.AlternateBidderCode)
}

if bidExtJSON, err := makeBidExtJSON(bid.Bid.Ext, bidExtPrebid, impExtInfoMap, bid.Bid.ImpID, bid.OriginalBidCPM, bid.OriginalBidCur, adapterCode); err != nil {
errs = append(errs, err)
} else {
result = append(result, *bid.Bid)
Expand Down
Loading
Loading