Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log error returned by PBS #2335

Merged
merged 1 commit into from
Apr 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions modules/prebidServerBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,9 @@ const LEGACY_PROTOCOL = {
if (bidder.no_cookie) {
doBidderSync(bidder.usersync.type, bidder.usersync.url, bidder.bidder);
}
if (bidder.error) {
utils.logWarn(`Prebid Server returned error: '${bidder.error}' for ${bidder.bidder}`);
}
});
}

Expand Down
31 changes: 31 additions & 0 deletions test/spec/modules/prebidServerBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,15 @@ const RESPONSE_OPENRTB_VIDEO = {
},
};

const RESPONSE_UNSUPPORTED_BIDDER = {
'tid': '437fbbf5-33f5-487a-8e16-a7112903cfe5',
'status': 'OK',
'bidder_status': [{
'bidder': '33Across',
'error': 'Unsupported bidder'
}]
};

describe('S2S Adapter', () => {
let adapter,
addBidResponse = sinon.spy(),
Expand Down Expand Up @@ -559,6 +568,7 @@ describe('S2S Adapter', () => {

describe('response handler', () => {
let server;
let logWarnSpy;

beforeEach(() => {
server = sinon.fakeServer.create();
Expand All @@ -569,6 +579,7 @@ describe('S2S Adapter', () => {
sinon.stub(utils, 'getBidRequest').returns({
bidId: '123'
});
logWarnSpy = sinon.spy(utils, 'logWarn');
});

afterEach(() => {
Expand All @@ -578,6 +589,7 @@ describe('S2S Adapter', () => {
utils.insertUserSyncIframe.restore();
utils.logError.restore();
cookie.cookieSet.restore();
logWarnSpy.restore();
});

// TODO: test dependent on pbjs_api_spec. Needs to be isolated
Expand Down Expand Up @@ -810,6 +822,25 @@ describe('S2S Adapter', () => {
expect(response).to.have.property('adId', '123');
expect(response).to.have.property('cpm', 10);
});

it('should log warning for unsupported bidder', () => {
server.respondWith(JSON.stringify(RESPONSE_UNSUPPORTED_BIDDER));

const s2sConfig = Object.assign({}, CONFIG, {
bidders: ['33Across']
});

const _config = {
s2sConfig: s2sConfig,
}

config.setConfig(_config);
config.setConfig({s2sConfig: CONFIG});
adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax);
server.respond();

sinon.assert.calledOnce(logWarnSpy);
});
});

describe('s2sConfig', () => {
Expand Down