Skip to content

Commit

Permalink
Prebid core: fix exception in rejection logic for bids that have inva…
Browse files Browse the repository at this point in the history
…lid requestId (prebid#9175)
  • Loading branch information
dgirardi authored and jorgeluisrocha committed May 18, 2023
1 parent f7655d5 commit 80cacbe
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/auction.js
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ export function auctionCallbacks(auctionDone, auctionInstance, {index = auctionM
return handleBidResponse(adUnitCode, bid, (done) => {
// return a "NO_BID" replacement that the caller can decide to continue with
// TODO: remove this in v8; see https://github.com/prebid/Prebid.js/issues/8956
const noBid = createBid(CONSTANTS.STATUS.NO_BID, bid.getIdentifiers());
const noBid = createBid(CONSTANTS.STATUS.NO_BID, bid.getIdentifiers?.());
Object.assign(noBid, Object.fromEntries(Object.entries(bid).filter(([k]) => !noBid.hasOwnProperty(k) && ![
'ad',
'adUrl',
Expand Down
9 changes: 9 additions & 0 deletions test/spec/auctionmanager_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1641,6 +1641,15 @@ describe('auctionmanager.js', function () {
});
});

it('should return NO_BID replacement when rejected bid is not a "proper" bid', () => {
const noBid = cbs.addBidResponse.reject(AU_CODE, {});
sinon.assert.match(noBid, {
status: CONSTANTS.BID_STATUS.BID_REJECTED,
statusMessage: 'Bid returned empty or error response',
cpm: 0,
});
})

it('addBidResponse hooks should not be able to reject the same bid twice', () => {
cbs.addBidResponse(AU_CODE, bid);
expect(auction.addBidRejected.calledOnce).to.be.true;
Expand Down

0 comments on commit 80cacbe

Please sign in to comment.