diff --git a/adapters/rubicon/rubicon.go b/adapters/rubicon/rubicon.go index 46caf262108..dad85ee1184 100644 --- a/adapters/rubicon/rubicon.go +++ b/adapters/rubicon/rubicon.go @@ -21,6 +21,8 @@ import ( "github.com/prebid/prebid-server/openrtb_ext" ) +const badvLimitSize = 50 + type RubiconAdapter struct { http *adapters.HTTPAdapter URI string @@ -740,6 +742,13 @@ func (a *RubiconAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adap request.App = &appCopy } + reqBadv := request.BAdv + if reqBadv != nil { + if len(reqBadv) > badvLimitSize { + request.BAdv = reqBadv[:badvLimitSize] + } + } + request.Imp = []openrtb.Imp{thisImp} request.Cur = nil request.Ext = nil diff --git a/adapters/rubicon/rubicon_test.go b/adapters/rubicon/rubicon_test.go index d386daed5b1..96623659d08 100644 --- a/adapters/rubicon/rubicon_test.go +++ b/adapters/rubicon/rubicon_test.go @@ -7,6 +7,7 @@ import ( "io/ioutil" "net/http" "net/http/httptest" + "strconv" "testing" "time" @@ -1133,6 +1134,48 @@ func TestOpenRTBRequestWithImpAndAdSlotIncluded(t *testing.T) { "Unexpected dfp_ad_unit_code: %s", rubiconExtInventory["dfp_ad_unit_code"]) } +func TestOpenRTBRequestWithBadvOverflowed(t *testing.T) { + SIZE_ID := getTestSizes() + bidder := new(RubiconAdapter) + + badvOverflowed := make([]string, 100) + for i := range badvOverflowed { + badvOverflowed[i] = strconv.Itoa(i) + } + + request := &openrtb.BidRequest{ + ID: "test-request-id", + BAdv: badvOverflowed, + Imp: []openrtb.Imp{{ + ID: "test-imp-id", + Banner: &openrtb.Banner{ + Format: []openrtb.Format{ + SIZE_ID[15], + }, + }, + Ext: json.RawMessage(`{ + "bidder": { + "zoneId": 8394, + "siteId": 283282, + "accountId": 7891, + "inventory": {"key1" : "val1"}, + "visitor": {"key2" : "val2"} + } + }`), + }}, + } + + reqs, _ := bidder.MakeRequests(request, &adapters.ExtraRequestInfo{}) + + rubiconReq := &openrtb.BidRequest{} + if err := json.Unmarshal(reqs[0].Body, rubiconReq); err != nil { + t.Fatalf("Unexpected error while decoding request: %s", err) + } + + badvRequest := rubiconReq.BAdv + assert.Equal(t, badvOverflowed[:50], badvRequest, "Unexpected dfp_ad_unit_code: %s") +} + func TestOpenRTBRequestWithSpecificExtUserEids(t *testing.T) { SIZE_ID := getTestSizes() bidder := new(RubiconAdapter)