diff --git a/openrtb_ext/convert_up.go b/openrtb_ext/convert_up.go index 2cfb07fb07..cfc9259b20 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 f83b85be89..2b5c230389 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", diff --git a/openrtb_ext/imp.go b/openrtb_ext/imp.go index e02cfadc59..85be312454 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 650a1efbe9..73851238d0 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"}}},