Skip to content

Commit

Permalink
PBS Adapter: handle edge case with duplicated EID permissions (#12595)
Browse files Browse the repository at this point in the history
* PBS Adapter: handle edge case with duplicated EID permissions

* fix lint
  • Loading branch information
dgirardi authored Dec 19, 2024
1 parent cb18124 commit 2f713dd
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
6 changes: 3 additions & 3 deletions modules/prebidServerBidAdapter/bidderConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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};
}

/**
Expand Down
17 changes: 16 additions & 1 deletion test/spec/modules/prebidServerBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2130,7 +2130,7 @@ describe('S2S Adapter', function () {
bidders: [],
source: 'idD'
}]);
})
});

it('should repeat global EIDs when bidder-specific EIDs conflict', () => {
BID_REQUESTS.push({
Expand Down Expand Up @@ -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, () => {
Expand Down

0 comments on commit 2f713dd

Please sign in to comment.