From 4c75e89779c1e2e5f84b9b04e7d50b48302a3053 Mon Sep 17 00:00:00 2001 From: Michel Chretien Date: Wed, 20 Nov 2024 17:32:50 +0100 Subject: [PATCH 1/2] ORTB 2.6: Fix unnecessary setPrebid from moveRewardedFromPrebidExtTo26 --- openrtb_ext/convert_up.go | 2 +- openrtb_ext/convert_up_test.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/openrtb_ext/convert_up.go b/openrtb_ext/convert_up.go index 2cfb07fb071..cfc9259b206 100644 --- a/openrtb_ext/convert_up.go +++ b/openrtb_ext/convert_up.go @@ -168,7 +168,7 @@ func moveRewardedFromPrebidExtTo26(i *ImpWrapper) { // read and clear prebid ext impExt, _ := i.GetImpExt() rwddPrebidExt := (*int8)(nil) - if p := impExt.GetPrebid(); p != nil { + if p := impExt.GetPrebid(); p != nil && p.IsRewardedInventory != nil { rwddPrebidExt = p.IsRewardedInventory p.IsRewardedInventory = nil impExt.SetPrebid(p) diff --git a/openrtb_ext/convert_up_test.go b/openrtb_ext/convert_up_test.go index f83b85be897..2b5c2303897 100644 --- a/openrtb_ext/convert_up_test.go +++ b/openrtb_ext/convert_up_test.go @@ -417,12 +417,12 @@ func TestMoveRewardedFromPrebidExtTo26(t *testing.T) { { description: "Not Present - Null Prebid Ext", givenImp: openrtb2.Imp{Ext: json.RawMessage(`{"prebid":null}`)}, - expectedImp: openrtb2.Imp{}, // empty prebid object pruned by RebuildImp + expectedImp: openrtb2.Imp{Ext: json.RawMessage(`{"prebid":null}`)}, }, { description: "Not Present - Empty Prebid Ext", givenImp: openrtb2.Imp{Ext: json.RawMessage(`{"prebid":{}}`)}, - expectedImp: openrtb2.Imp{}, // empty prebid object pruned by RebuildImp + expectedImp: openrtb2.Imp{Ext: json.RawMessage(`{"prebid":{}}`)}, }, { description: "Prebid Ext Migrated To 2.6", From 0db4d27d0ad690e358f1267ad717481c0894ba16 Mon Sep 17 00:00:00 2001 From: Michel Chretien Date: Wed, 20 Nov 2024 17:33:44 +0100 Subject: [PATCH 2/2] ORTB: Fix missing adUnitCode from imp.ext.prebid --- openrtb_ext/imp.go | 2 ++ openrtb_ext/request_wrapper_test.go | 13 +++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/openrtb_ext/imp.go b/openrtb_ext/imp.go index e02cfadc593..85be3124548 100644 --- a/openrtb_ext/imp.go +++ b/openrtb_ext/imp.go @@ -43,6 +43,8 @@ type ExtImpPrebid struct { Options *Options `json:"options,omitempty"` + AdUnitCode string `json:"adunitcode,omitempty"` + Passthrough json.RawMessage `json:"passthrough,omitempty"` Floors *ExtImpPrebidFloors `json:"floors,omitempty"` diff --git a/openrtb_ext/request_wrapper_test.go b/openrtb_ext/request_wrapper_test.go index 650a1efbe93..73851238d00 100644 --- a/openrtb_ext/request_wrapper_test.go +++ b/openrtb_ext/request_wrapper_test.go @@ -189,8 +189,10 @@ func TestUserExt(t *testing.T) { func TestRebuildImp(t *testing.T) { var ( - prebid = &ExtImpPrebid{IsRewardedInventory: openrtb2.Int8Ptr(1)} - prebidJson = json.RawMessage(`{"prebid":{"is_rewarded_inventory":1}}`) + prebid = &ExtImpPrebid{IsRewardedInventory: openrtb2.Int8Ptr(1)} + prebidJson = json.RawMessage(`{"prebid":{"is_rewarded_inventory":1}}`) + prebidWithAdunitCode = &ExtImpPrebid{AdUnitCode: "adunitcode"} + prebidWithAdunitCodeJson = json.RawMessage(`{"prebid":{"adunitcode":"adunitcode"}}`) ) testCases := []struct { @@ -220,6 +222,13 @@ func TestRebuildImp(t *testing.T) { expectedRequest: openrtb2.BidRequest{Imp: []openrtb2.Imp{{ID: "2", Ext: prebidJson}}}, expectedAccessed: true, }, + { + description: "One - Accessed - Dirty - AdUnitCode", + request: openrtb2.BidRequest{Imp: []openrtb2.Imp{{ID: "1"}}}, + requestImpWrapper: []*ImpWrapper{{Imp: &openrtb2.Imp{ID: "1"}, impExt: &ImpExt{prebid: prebidWithAdunitCode, prebidDirty: true}}}, + expectedRequest: openrtb2.BidRequest{Imp: []openrtb2.Imp{{ID: "1", Ext: prebidWithAdunitCodeJson}}}, + expectedAccessed: true, + }, { description: "One - Accessed - Error", request: openrtb2.BidRequest{Imp: []openrtb2.Imp{{ID: "1"}}},