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

UOE-11665: Fix-Panic for AppLovin requests if the multi-bid multi-floor feature is enabled for the profile but not configured for certain ad units #977

Merged
merged 3 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion analytics/pubmatic/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ var send = func(rCtx *models.RequestCtx, url string, headers http.Header, mhc mh

// RestoreBidResponse restores the original bid response for AppLovinMax from the signal data
func RestoreBidResponse(rctx *models.RequestCtx, ao analytics.AuctionObject) error {
if rctx.Endpoint != models.EndpointAppLovinMax {
if rctx.Endpoint != models.EndpointAppLovinMax || rctx.AppLovinMax.Reject {
AvinashKapre marked this conversation as resolved.
Show resolved Hide resolved
return nil
}

Expand Down
19 changes: 19 additions & 0 deletions analytics/pubmatic/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,25 @@ func TestRestoreBidResponse(t *testing.T) {
ID: "test-case-1",
},
},
{
name: "AppLovinMax.Reject is true",
args: args{
ao: analytics.AuctionObject{
Response: &openrtb2.BidResponse{
ID: "test-case-1",
},
},
rctx: &models.RequestCtx{
Endpoint: models.EndpointAppLovinMax,
AppLovinMax: models.AppLovinMax{
Reject: true,
},
},
},
want: &openrtb2.BidResponse{
ID: "test-case-1",
},
},
{
name: "NBR is not nil",
args: args{
Expand Down
2 changes: 1 addition & 1 deletion analytics/pubmatic/pubmatic.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (ow HTTPLogger) LogAuctionObject(ao *analytics.AuctionObject) {

err := RestoreBidResponse(rCtx, *ao)
if err != nil {
glog.Error("Failed to restore bid response for pub:[%d], profile:[%d], version:[%d], err:[%s].", rCtx.PubID, rCtx.ProfileID, rCtx.VersionID, err.Error())
glog.Errorf("Failed to restore bid response for pub:[%d], profile:[%d], version:[%d], err:[%s].", rCtx.PubID, rCtx.ProfileID, rCtx.VersionID, err.Error())
}

loggerURL, headers := GetLogAuctionObjectAsURL(*ao, rCtx, false, false)
Expand Down
6 changes: 4 additions & 2 deletions modules/pubmatic/openwrap/defaultbids.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ func (m *OpenWrap) addDefaultBidsForMultiFloorsConfig(rctx *models.RequestCtx, b

defaultBids := rctx.DefaultBids
bidderExcludeFloors := make(map[string]struct{}, len(bidResponse.SeatBid)) //exclude floors which are already present in bidresponse
var adunitFloors []float64 //floors for each adunit

for _, seatBid := range bidResponse.SeatBid {
if rctx.PrebidBidderCode[seatBid.Seat] == models.BidderPubMatic || rctx.PrebidBidderCode[seatBid.Seat] == models.BidderPubMaticSecondaryAlias {
Expand All @@ -204,7 +203,10 @@ func (m *OpenWrap) addDefaultBidsForMultiFloorsConfig(rctx *models.RequestCtx, b
}

for impID, impCtx := range rctx.ImpBidCtx {
adunitFloors = rctx.AppLovinMax.MultiFloorsConfig.Config[impCtx.TagID]
adunitFloors, ok := rctx.AppLovinMax.MultiFloorsConfig.Config[impCtx.TagID]
if !ok {
AvinashKapre marked this conversation as resolved.
Show resolved Hide resolved
continue
}
for bidder := range impCtx.Bidders {
if prebidBidderCode := rctx.PrebidBidderCode[bidder]; prebidBidderCode != models.BidderPubMatic && prebidBidderCode != models.BidderPubMaticSecondaryAlias {
continue
Expand Down
58 changes: 58 additions & 0 deletions modules/pubmatic/openwrap/defaultbids_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,64 @@ func TestOpenWrap_addDefaultBidsForMultiFloorsConfig(t *testing.T) {
},
},
},
{
AvinashKapre marked this conversation as resolved.
Show resolved Hide resolved
name: "mulit-floors config do not have adunit configured and no bids in the response",
args: args{
rctx: &models.RequestCtx{
Endpoint: models.EndpointAppLovinMax,
DefaultBids: map[string]map[string][]openrtb2.Bid{
"test-impID-1": {
"pubmatic": {
{
ID: "dbbsdhkldks1234",
ImpID: "test-impID-1",
Ext: []byte(`{}`),
},
},
},
},
AppLovinMax: models.AppLovinMax{
MultiFloorsConfig: models.MultiFloorsConfig{
Enabled: true,
Config: models.ApplovinAdUnitFloors{
"adunit-1": []float64{1.1, 2.1, 3.1},
},
},
},
ImpBidCtx: map[string]models.ImpCtx{
"test-impID-1": {
TagID: "adunit-2",
Bidders: map[string]models.PartnerData{
"pubmatic": {
PrebidBidderCode: "pubmatic",
},
},
BidCtx: map[string]models.BidCtx{},
},
},
PrebidBidderCode: map[string]string{
"pubmatic": "pubmatic",
},
},
bidResponse: &openrtb2.BidResponse{
ID: "bid-1",
},
},
fields: fields{
uuidGenerator: TestUUIDGenerator{},
},
want: map[string]map[string][]openrtb2.Bid{
"test-impID-1": {
"pubmatic": {
{
ID: "dbbsdhkldks1234",
ImpID: "test-impID-1",
Ext: []byte(`{}`),
},
},
},
},
},
{
name: "mulit-floors config have three floors and only one bid in the response",
args: args{
Expand Down
Loading