Skip to content

Commit

Permalink
PBS Adapter: only include known bidders in eidpermissions (#12594)
Browse files Browse the repository at this point in the history
  • Loading branch information
dgirardi authored Dec 18, 2024
1 parent d3f3696 commit cc2e8d2
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
9 changes: 6 additions & 3 deletions modules/prebidServerBidAdapter/bidderConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export function consolidateEids({eids, conflicts = new Set()}) {
}
}

function replaceEids({global, bidder}) {
function replaceEids({global, bidder}, requestedBidders) {
const consolidated = consolidateEids(extractEids({global, bidder}));
global = deepClone(global);
bidder = deepClone(bidder);
Expand All @@ -134,6 +134,9 @@ function replaceEids({global, bidder}) {
if (consolidated.global.length) {
deepSetValue(global, 'user.ext.eids', consolidated.global);
}
if (requestedBidders?.length) {
consolidated.permissions.forEach((permission) => permission.bidders = permission.bidders.filter(bidder => requestedBidders.includes(bidder)));
}
if (consolidated.permissions.length) {
deepSetValue(global, 'ext.prebid.data.eidpermissions', consolidated.permissions);
}
Expand All @@ -145,11 +148,11 @@ function replaceEids({global, bidder}) {
return {global, bidder}
}

export function premergeFpd(ortb2Fragments) {
export function premergeFpd(ortb2Fragments, requestedBidders) {
if (ortb2Fragments == null || Object.keys(ortb2Fragments.bidder || {}).length === 0) {
return ortb2Fragments;
} else {
ortb2Fragments = replaceEids(ortb2Fragments);
ortb2Fragments = replaceEids(ortb2Fragments, requestedBidders);
return {
...ortb2Fragments,
bidder: getPBSBidderConfig(ortb2Fragments)
Expand Down
2 changes: 1 addition & 1 deletion modules/prebidServerBidAdapter/ortbConverter.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ export function buildPBSRequest(s2sBidRequest, bidderRequests, adUnits, requeste
requestTimestamp,
s2sBidRequest: {
...s2sBidRequest,
ortb2Fragments: premergeFpd(s2sBidRequest.ortb2Fragments)
ortb2Fragments: premergeFpd(s2sBidRequest.ortb2Fragments, requestedBidders)
},
requestedBidders,
actualBidderRequests: bidderRequests,
Expand Down
21 changes: 19 additions & 2 deletions test/spec/modules/prebidServerBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2115,6 +2115,23 @@ describe('S2S Adapter', function () {
}]);
});

it('should not set eidpermissions for unrequested bidders', () => {
req.ortb2Fragments.bidder.unknown = {
user: {
eids: [{source: 'idC', id: 3}, {source: 'idD', id: 4}]
}
}
adapter.callBids(req, BID_REQUESTS, addBidResponse, done, ajax);
const payload = JSON.parse(server.requests[0].requestBody);
expect(payload.ext.prebid.data.eidpermissions).to.eql([{
bidders: ['appnexus'],
source: 'idC'
}, {
bidders: [],
source: 'idD'
}]);
})

it('should repeat global EIDs when bidder-specific EIDs conflict', () => {
BID_REQUESTS.push({
...BID_REQUESTS[0],
Expand Down Expand Up @@ -4710,8 +4727,8 @@ describe('S2S Adapter', function () {
bidder: {
bidderA: [mkEid('idA', 'idA2')]
}
})
})
});
});
})
});
});

0 comments on commit cc2e8d2

Please sign in to comment.