Skip to content

Commit

Permalink
Fix short-circuit in building out imp[].ext
Browse files Browse the repository at this point in the history
  • Loading branch information
dgirardi committed Mar 16, 2022
1 parent 160d6f3 commit 9712b52
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion modules/prebidServerBidAdapter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ Object.assign(ORTB2.prototype, {
// get bidder params in form { <bidder code>: {...params} }
// initialize reduce function with the user defined `ext` properties on the ad unit
const ext = adUnit.bids.reduce((acc, bid) => {
if (bid.bidder == null) return;
if (bid.bidder == null) return acc;
const adapter = adapterManager.bidderRegistry[bid.bidder];
if (adapter && adapter.getSpec().transformBidParams) {
bid.params = adapter.getSpec().transformBidParams(bid.params, true, adUnit, bidRequests);
Expand Down
11 changes: 11 additions & 0 deletions test/spec/modules/prebidServerBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2483,6 +2483,17 @@ describe('S2S Adapter', function () {
sinon.assert.calledWith(addBidResponse, sinon.match.any, sinon.match({bidderCode: 'storedImpression', requestId: 'testId'}))
});

it('copies ortb2Imp to response when there is only a null bid', () => {
const cfg = {...CONFIG};
config.setConfig({s2sConfig: cfg});
const ortb2Imp = {ext: {prebid: {storedrequest: 'value'}}};
const req = {...REQUEST, s2sConfig: cfg, ad_units: [{...REQUEST.ad_units[0], bids: [{bidder: null, bid_id: 'testId'}], ortb2Imp}]};
const bidReq = {...BID_REQUESTS[0], bidderCode: null, bids: [{...BID_REQUESTS[0].bids[0], bidder: null, bidId: 'testId'}]}
adapter.callBids(req, [bidReq], addBidResponse, done, ajax);
const actual = JSON.parse(server.requests[0].requestBody);
sinon.assert.match(actual.imp[0], sinon.match(ortb2Imp));
});

describe('on sync requested with no cookie', () => {
let cfg, req, csRes;

Expand Down

0 comments on commit 9712b52

Please sign in to comment.