Skip to content

Commit

Permalink
Revert "surround getFloor in try catch (prebid#5628)"
Browse files Browse the repository at this point in the history
This reverts commit f8c2226.
  • Loading branch information
BrightMountainMedia authored Sep 14, 2020
1 parent 4405b05 commit d1c7f97
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 48 deletions.
30 changes: 10 additions & 20 deletions modules/rubiconBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,16 +203,11 @@ export const spec = {

let bidFloor;
if (typeof bidRequest.getFloor === 'function' && !config.getConfig('rubicon.disableFloors')) {
let floorInfo;
try {
floorInfo = bidRequest.getFloor({
currency: 'USD',
mediaType: 'video',
size: parseSizes(bidRequest, 'video')
});
} catch (e) {
utils.logError('Rubicon: getFloor threw an error: ', e);
}
let floorInfo = bidRequest.getFloor({
currency: 'USD',
mediaType: 'video',
size: parseSizes(bidRequest, 'video')
});
bidFloor = typeof floorInfo === 'object' && floorInfo.currency === 'USD' && !isNaN(parseInt(floorInfo.floor)) ? parseFloat(floorInfo.floor) : undefined;
} else {
bidFloor = parseFloat(utils.deepAccess(bidRequest, 'params.floor'));
Expand Down Expand Up @@ -532,16 +527,11 @@ export const spec = {

// If floors module is enabled and we get USD floor back, send it in rp_hard_floor else undfined
if (typeof bidRequest.getFloor === 'function' && !config.getConfig('rubicon.disableFloors')) {
let floorInfo;
try {
floorInfo = bidRequest.getFloor({
currency: 'USD',
mediaType: 'video',
size: parseSizes(bidRequest, 'video')
});
} catch (e) {
utils.logError('Rubicon: getFloor threw an error: ', e);
}
let floorInfo = bidRequest.getFloor({
currency: 'USD',
mediaType: 'banner',
size: '*'
});
data['rp_hard_floor'] = typeof floorInfo === 'object' && floorInfo.currency === 'USD' && !isNaN(parseInt(floorInfo.floor)) ? floorInfo.floor : undefined;
}

Expand Down
29 changes: 1 addition & 28 deletions test/spec/modules/rubiconBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ describe('the rubicon adapter', function () {
let sandbox,
bidderRequest,
sizeMap,
getFloorResponse,
logErrorSpy;
getFloorResponse;

/**
* @typedef {Object} sizeMapConverted
Expand Down Expand Up @@ -273,7 +272,6 @@ describe('the rubicon adapter', function () {

beforeEach(function () {
sandbox = sinon.sandbox.create();
logErrorSpy = sinon.spy(utils, 'logError');
getFloorResponse = {};
bidderRequest = {
bidderCode: 'rubicon',
Expand Down Expand Up @@ -345,7 +343,6 @@ describe('the rubicon adapter', function () {

afterEach(function () {
sandbox.restore();
utils.logError.restore();
});

describe('MAS mapping / ordering', function () {
Expand Down Expand Up @@ -1600,30 +1597,6 @@ describe('the rubicon adapter', function () {
[request] = spec.buildRequests(bidderRequest.bids, bidderRequest);
expect(request.data.imp[0].bidfloor).to.equal(1.23);
});

it('should continue with auction and log error if getFloor throws one', function () {
createVideoBidderRequest();
// default getFloor response is empty object so should not break and not send hard_floor
bidderRequest.bids[0].getFloor = () => {
throw new Error('An exception!');
};
sandbox.stub(Date, 'now').callsFake(() =>
bidderRequest.auctionStart + 100
);

let [request] = spec.buildRequests(bidderRequest.bids, bidderRequest);

// log error called
expect(logErrorSpy.calledOnce).to.equal(true);

// should have an imp
expect(request.data.imp).to.exist.and.to.be.a('array');
expect(request.data.imp).to.have.lengthOf(1);

// should be NO bidFloor
expect(request.data.imp[0].bidfloor).to.be.undefined;
});

it('should add alias name to PBS Request', function() {
createVideoBidderRequest();

Expand Down

0 comments on commit d1c7f97

Please sign in to comment.