Skip to content

Commit

Permalink
Rubicon Bid Adapter: fix hb_size undefined value for native media type (
Browse files Browse the repository at this point in the history
prebid#12039)

* Fix hb_size undefined value for native media type

* Add unit test for native bids width and height
  • Loading branch information
apukh-magnite authored Jul 28, 2024
1 parent ac84d65 commit d979682
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
6 changes: 3 additions & 3 deletions modules/rubiconBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,9 @@ export const converter = ortbConverter({
const {bidRequest} = context;

let [parseSizeWidth, parseSizeHeight] = bidRequest.mediaTypes.video?.context === 'outstream' ? parseSizes(bidRequest, VIDEO) : [undefined, undefined];

bidResponse.width = bid.w || parseSizeWidth || bidResponse.playerWidth;
bidResponse.height = bid.h || parseSizeHeight || bidResponse.playerHeight;
// 0 by default to avoid undefined size
bidResponse.width = bid.w || parseSizeWidth || bidResponse.playerWidth || 0;
bidResponse.height = bid.h || parseSizeHeight || bidResponse.playerHeight || 0;

if (bidResponse.mediaType === VIDEO && bidRequest.mediaTypes.video.context === 'outstream') {
bidResponse.renderer = outstreamRenderer(bidResponse);
Expand Down
10 changes: 10 additions & 0 deletions test/spec/modules/rubiconBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3987,6 +3987,16 @@ describe('the rubicon adapter', function () {
let bids = spec.interpretResponse({body: response}, {data: request});
expect(bids).to.have.nested.property('[0].native');
});
it('should set 0 to bids width and height if `w` and `h` in response object not defined', () => {
const nativeBidderRequest = addNativeToBidRequest(bidderRequest);
const request = converter.toORTB({bidderRequest: nativeBidderRequest, bidRequests: nativeBidderRequest.bids});
let response = getNativeResponse({impid: request.imp[0].id});
delete response.seatbid[0].bid[0].w;
delete response.seatbid[0].bid[0].h
let bids = spec.interpretResponse({body: response}, {data: request});
expect(bids[0].width).to.equal(0);
expect(bids[0].height).to.equal(0);
})
});
}

Expand Down

0 comments on commit d979682

Please sign in to comment.