Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prebid core: fix exception in rejection logic for bids that have invalid requestId #9175

Merged
merged 1 commit into from
Nov 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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