Skip to content

pbjs.requestBids calls the bidsBackHandler with the wrong arguments in V10 #14652

@robin-crazygames

Description

@robin-crazygames

In the docs for the bidsBackHandler, you get referred to the getBidResponses doc for the bids argument with which the bidsBackHandler is called.

In V10, the return value for getBidResponses has been changed to an array, while retaining the .bids property for backwards compatibility.
This is reflected in the types:

function getBidReponses(): ByAdUnit<WrapInBids<Bid>>

It isn't reflected in the docs yet, but I already opened a PR in the docs repo to correct this.

As such, I expect that the bidsBackHandler receives a bids argument of the same type: ByAdUnit<WrapInBids<Bid>>.
Looking at the types of the bidsBackHandler in the RequestBidsOptions type, that expectation is correct:

bidsBackHandler?: (bids?: RequestBidsResult['bids'], ...) => void;

and

type RequestBidsResult = {
  bids?: ByAdUnit<WrapsInBids<Bid>>;
  ...
}

However, bids still seems to be a map where the ad unit is the key, and the value is an object with a bids property. The value isn't an array. So it is still the same return type as in V9, and doesn't match the typescript types.

The problem is in auction.ts#groupByPlacement:

function groupByPlacement(bidsByPlacement, bid) {
  if (!bidsByPlacement[bid.adUnitCode]) { bidsByPlacement[bid.adUnitCode] = { bids: [] }; }
  bidsByPlacement[bid.adUnitCode].bids.push(bid);
  return bidsByPlacement;
}

This creates an object and not an arrray with the .bids property

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions