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

4235 prebid endpoint return empty array instead of 204 when no bids returned #3136

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
20 changes: 16 additions & 4 deletions modules/playgroundxyzBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { registerBidder } from 'src/adapters/bidderFactory';
import { BANNER } from 'src/mediaTypes';

const BIDDER_CODE = 'playgroundxyz';
const URL = 'https://ads.playground.xyz/host-config/prebid';
const URL = 'https://ads.playground.xyz/host-config/prebid?v=2';

export const spec = {
code: BIDDER_CODE,
aliases: ['playgroundxyz'],
aliases: ['playgroundxyz', 'pxyz'],
supportedMediaTypes: [BANNER],

/**
Expand Down Expand Up @@ -69,8 +69,10 @@ export const spec = {

if (!serverResponse || serverResponse.error) {
let errorMessage = `in response for ${bidderRequest.bidderCode} adapter`;
if (serverResponse && serverResponse.error) { errorMessage += `: ${serverResponse.error}`; }
utils.logError(errorMessage);
if (serverResponse && serverResponse.error) {
errorMessage += `: ${serverResponse.error}`;
utils.logError(errorMessage);
}
return bids;
}

Expand All @@ -80,6 +82,10 @@ export const spec = {
return bids;
}

if (!serverResponse.seatbid) {
return bids;
}

serverResponse.seatbid.forEach(sBid => {
if (sBid.hasOwnProperty('bid')) {
sBid.bid.forEach(iBid => {
Expand Down Expand Up @@ -131,6 +137,12 @@ function mapImpression(bid) {
ext: {
appnexus: {
placement_id: parseInt(bid.params.placementId, 10)
},
pxyz: {
adapter: {
vendor: 'prebid',
prebid: '$prebid.version$'
}
}
}
};
Expand Down
8 changes: 4 additions & 4 deletions test/spec/modules/playgroundxyzBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { spec } from 'modules/playgroundxyzBidAdapter';
import { newBidder } from 'src/adapters/bidderFactory';
import { deepClone } from 'src/utils';

const URL = 'https://ads.playground.xyz/host-config/prebid';
const URL = 'https://ads.playground.xyz/host-config/prebid?v=2';
const GDPR_CONSENT = 'XYZ-CONSENT';

describe('playgroundxyzBidAdapter', function () {
Expand Down Expand Up @@ -64,7 +64,7 @@ describe('playgroundxyzBidAdapter', function () {
const data = JSON.parse(request.data);
const banner = data.imp[0].banner;

expect(Object.keys(data.imp[0].ext)).to.have.members(['appnexus']);
expect(Object.keys(data.imp[0].ext)).to.have.members(['appnexus', 'pxyz']);
expect([banner.w, banner.h]).to.deep.equal([300, 250]);
expect(banner.format).to.deep.equal([{w: 300, h: 250}, {w: 300, h: 600}]);
expect(request.url).to.equal(URL);
Expand Down Expand Up @@ -128,8 +128,8 @@ describe('playgroundxyzBidAdapter', function () {
expect(Object.keys(result[0])).to.have.members(Object.keys(expectedResponse[0]));
});

it('handles nobid responses', function () {
let response = '';
it('handles nobid response', function () {
const response = undefined;
let result = spec.interpretResponse({ body: response }, {bidderRequest});
expect(result.length).to.equal(0);
});
Expand Down