From 060a01d8dac89abff47cbfffd9d3197edbb74293 Mon Sep 17 00:00:00 2001 From: Demetrio Girardi Date: Wed, 18 Dec 2024 11:24:24 -0800 Subject: [PATCH 1/2] PBS Adapter: handle edge case with duplicated EID permissions --- modules/prebidServerBidAdapter/bidderConfig.js | 6 +++--- .../spec/modules/prebidServerBidAdapter_spec.js | 17 ++++++++++++++++- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/modules/prebidServerBidAdapter/bidderConfig.js b/modules/prebidServerBidAdapter/bidderConfig.js index 3b51810ff20..f6f4fb91389 100644 --- a/modules/prebidServerBidAdapter/bidderConfig.js +++ b/modules/prebidServerBidAdapter/bidderConfig.js @@ -52,7 +52,7 @@ export function extractEids({global, bidder}) { function getEntry(eid) { let entry = entries.find((candidate) => deepEqual(candidate.eid, eid)); if (entry == null) { - entry = {eid, bidders: []} + entry = {eid, bidders: new Set()} entries.push(entry); } if (bySource[eid.source] == null) { @@ -74,12 +74,12 @@ export function extractEids({global, bidder}) { (deepAccess(bidderConfig, path) || []).forEach(eid => { const entry = getEntry(eid); if (entry.bidders !== false) { - entry.bidders.push(bidderCode); + entry.bidders.add(bidderCode); } }) }) }) - return {eids: entries, conflicts}; + return {eids: entries.map(({eid, bidders}) => ({eid, bidders: bidders && Array.from(bidders)})), conflicts}; } /** diff --git a/test/spec/modules/prebidServerBidAdapter_spec.js b/test/spec/modules/prebidServerBidAdapter_spec.js index 85ae7909f34..e7afe9c652a 100644 --- a/test/spec/modules/prebidServerBidAdapter_spec.js +++ b/test/spec/modules/prebidServerBidAdapter_spec.js @@ -2130,7 +2130,7 @@ describe('S2S Adapter', function () { bidders: [], source: 'idD' }]); - }) + }); it('should repeat global EIDs when bidder-specific EIDs conflict', () => { BID_REQUESTS.push({ @@ -4638,6 +4638,21 @@ describe('S2S Adapter', function () { ], conflicts: ['idA', 'idB'] } + }, + { + t: 'duplicated bidder-specific eids', + bidder: { + bidderA: { + user: { + eids: [mkEid('id'), mkEid('id')] + } + } + }, + expected: { + eids: [ + eidEntry('id', 'id',['bidderA']) + ] + } } ].forEach(({t, global = {}, bidder = {}, expected}) => { it(t, () => { From f9b0b7af9f55881e01a9a8cdf13e39c65ed4edc3 Mon Sep 17 00:00:00 2001 From: Demetrio Girardi Date: Wed, 18 Dec 2024 11:30:27 -0800 Subject: [PATCH 2/2] fix lint --- test/spec/modules/prebidServerBidAdapter_spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/spec/modules/prebidServerBidAdapter_spec.js b/test/spec/modules/prebidServerBidAdapter_spec.js index e7afe9c652a..fc0f9ed7b68 100644 --- a/test/spec/modules/prebidServerBidAdapter_spec.js +++ b/test/spec/modules/prebidServerBidAdapter_spec.js @@ -4650,7 +4650,7 @@ describe('S2S Adapter', function () { }, expected: { eids: [ - eidEntry('id', 'id',['bidderA']) + eidEntry('id', 'id', ['bidderA']) ] } }