From e5da6c8c75571c255a43233e33503f337ad358ff Mon Sep 17 00:00:00 2001 From: Jason Piros Date: Wed, 22 Jan 2025 15:16:50 -0700 Subject: [PATCH] Consumable Bid Adapter: remove EID non-objects (#12646) * consumableBidAdapter: remove eid non-objects * fix lint errors --- modules/consumableBidAdapter.js | 4 +- .../spec/modules/consumableBidAdapter_spec.js | 42 +++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/modules/consumableBidAdapter.js b/modules/consumableBidAdapter.js index cb802508de9..e01078890f9 100644 --- a/modules/consumableBidAdapter.js +++ b/modules/consumableBidAdapter.js @@ -33,7 +33,8 @@ export const spec = { /** * Make a server request from the list of BidRequests. * - * @param {validBidRequests[]} - an array of bids + * @param {validBidRequests[]} validBidRequests An array of bids + * @param {Object} bidderRequest The bidder's request info. * @return ServerRequest Info describing the request to the server. */ @@ -300,6 +301,7 @@ function retrieveAd(decision, unitId, unitName) { function handleEids(data, validBidRequests) { let bidUserIdAsEids = deepAccess(validBidRequests, '0.userIdAsEids'); if (isArray(bidUserIdAsEids) && bidUserIdAsEids.length > 0) { + bidUserIdAsEids = bidUserIdAsEids.filter(e => typeof e === 'object'); deepSetValue(data, 'user.eids', bidUserIdAsEids); } else { deepSetValue(data, 'user.eids', undefined); diff --git a/test/spec/modules/consumableBidAdapter_spec.js b/test/spec/modules/consumableBidAdapter_spec.js index 073e889d172..4b0eefd7e8d 100644 --- a/test/spec/modules/consumableBidAdapter_spec.js +++ b/test/spec/modules/consumableBidAdapter_spec.js @@ -755,6 +755,48 @@ describe('Consumable BidAdapter', function () { expect(data.user.eids).to.deep.equal(bidderRequest.bidRequest[0].userIdAsEids); }); + it('Request should remove non-objects for userIdAsEids', function () { + bidderRequest.bidRequest[0].userId = {}; + bidderRequest.bidRequest[0].userId.tdid = 'TTD_ID'; + bidderRequest.bidRequest[0].userIdAsEids = [ + { + source: 'adserver.org', + uids: [ + { + id: 'TTD_ID_FROM_USER_ID_MODULE', + atype: 1, + ext: { + rtiPartner: 'TDID', + }, + }, + ], + }, + 'RANDOM_IDENTIFIER_STRING' + ]; + let scrubbedEids = [ + { + source: 'adserver.org', + uids: [ + { + id: 'TTD_ID_FROM_USER_ID_MODULE', + atype: 1, + ext: { + rtiPartner: 'TDID', + }, + }, + ], + }, + ]; + let request = spec.buildRequests( + bidderRequest.bidRequest, + BIDDER_REQUEST_1 + ); + let data = JSON.parse(request.data); + expect(data.user.eids).to.deep.equal( + scrubbedEids + ); + }); + it('Request should NOT have adsrvrOrgId params if userId is NOT object', function() { let request = spec.buildRequests(bidderRequest.bidRequest, BIDDER_REQUEST_1); let data = JSON.parse(request.data);