Skip to content
This repository has been archived by the owner on Dec 22, 2022. It is now read-only.

Commit

Permalink
enforce video.size_id for video imps in rubicon adapter (prebid#1101)
Browse files Browse the repository at this point in the history
  • Loading branch information
Aadeshp authored and SyntaxNode committed Jan 6, 2020
1 parent a347880 commit 9b8b8da
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 4 deletions.
12 changes: 10 additions & 2 deletions adapters/rubicon/rubicon.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ import (
"context"
"encoding/json"
"fmt"
"github.com/golang/glog"
"github.com/prebid/prebid-server/pbs"
"io/ioutil"
"net/http"
"net/url"
"strings"

"github.com/golang/glog"
"github.com/prebid/prebid-server/pbs"

"golang.org/x/net/context/ctxhttp"

"github.com/mxmCherry/openrtb"
Expand Down Expand Up @@ -685,6 +686,13 @@ func (a *RubiconAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adap

isVideo := isVideo(thisImp)
if isVideo {
if rubiconExt.Video.VideoSizeID == 0 {
errs = append(errs, &errortypes.BadInput{
Message: fmt.Sprintf("imp[%d].ext.bidder.rubicon.video.size_id must be defined for video impression", i),
})
continue
}

videoCopy := *thisImp.Video
videoExt := rubiconVideoExt{Skip: rubiconExt.Video.Skip, SkipDelay: rubiconExt.Video.SkipDelay, RP: rubiconVideoExtRP{SizeID: rubiconExt.Video.VideoSizeID}}
videoCopy.Ext, err = json.Marshal(&videoExt)
Expand Down
5 changes: 3 additions & 2 deletions adapters/rubicon/rubicon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1244,8 +1244,9 @@ func TestOpenRTBRequestWithVideoImpEvenIfImpHasBannerButAllRequiredVideoFields(t
"zoneId": 8394,
"siteId": 283282,
"accountId": 7891,
"inventory": {"key1" : "val1"},
"visitor": {"key2" : "val2"}
"inventory": {"key1": "val1"},
"visitor": {"key2": "val2"},
"video": {"size_id": 1}
}}`),
}},
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"mockBidRequest": {
"id": "test-req-id",
"imp": [
{
"id": "test-imp-1",
"video": {
"w": 640,
"h": 480,
"linearity": 1
},
"ext": {
"bidder": {
"accountId": 1001,
"siteId":113932,
"zoneId":535510
}
}
}
],
"site": {
"page": "prebid.org"
}
},
"expectedMakeRequestsErrors": [
{
"value": "imp[0].ext.bidder.rubicon.video.size_id must be defined for video impression",
"comparison": "literal"
}
]
}

0 comments on commit 9b8b8da

Please sign in to comment.