Skip to content

PubstackAdapter: add default value for tll & netRevenue#14637

Merged
lksharma merged 13 commits intoprebid:masterfrom
pbstck:master
Apr 9, 2026
Merged

PubstackAdapter: add default value for tll & netRevenue#14637
lksharma merged 13 commits intoprebid:masterfrom
pbstck:master

Conversation

@sdeluce
Copy link
Copy Markdown
Contributor

@sdeluce sdeluce commented Mar 24, 2026

Type of change

  • Bugfix

  • Feature

  • New bidder adapter

  • Updated bidder adapter

  • Code style update (formatting, local variables)

  • Refactoring (no functional changes, no api changes)

  • Build related changes

  • CI related changes

  • Does this change affect user-facing APIs or examples documented on http://prebid.org/?

  • Other

Description of change

This PR fixes Pubstack bid response enrichment for OpenRTB responses that provide ttl and netRevenue fields outside of the default ORTB converter mapping.

The Pubstack adapter already relies on the ORTB converter for standard bid response fields, but some exchanges return:

  • seatbid[].bid[].ttl instead of seatbid[].bid[].exp
  • seatbid[].bid[].netRevenue instead of values supplied through converter context

To support these responses, the adapter enriches converted bids after fromORTB() by matching raw bids by impid and backfilling:

  • ttl from rawBid.ttl, then rawBid.exp, then the adapter default
  • netRevenue from rawBid.netRevenue, then the adapter default

This prevents valid Pubstack bids from being rejected by Prebid validation when these required fields are missing after ORTB conversion.

The change is scoped to the Pubstack bid adapter and includes test coverage for response mapping.

Other information

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8163b8da2c

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread modules/pubstackBidAdapter.ts Outdated
Comment on lines +122 to +126
const mapResponseBidsByImpId = (responseBody) => new Map<string, OpenRtbBid>(
(responseBody?.seatbid ?? [])
.flatMap(seatBid => seatBid?.bid ?? [])
.filter(bid => bid?.impid)
.map(bid => [bid.impid, bid]),
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep per-bid metadata instead of collapsing by impid

This mapping collapses all raw bids that share the same impid into a single entry, so when a response contains multiple bids for one impression (e.g., multiple seat bids on the same imp), enrichBidResponse() will apply the last raw bid’s ttl/netRevenue to every converted bid with that requestId. In those cases, earlier bids get incorrect metadata, which can change bid expiry behavior and net/gross revenue interpretation.

Useful? React with 👍 / 👎.

@gpolaert
Copy link
Copy Markdown
Contributor

@dgirardi

Regarding #14563, I implemented your suggestions regarding the element and the new helper. Is it okay?

@coveralls
Copy link
Copy Markdown
Collaborator

coveralls commented Mar 26, 2026

Coverage Report for CI Build 24089107179

Coverage increased (+0.001%) to 96.343%

Details

  • Coverage increased (+0.001%) from the base build.
  • Patch coverage: 59 of 59 lines across 2 files are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 224980
Covered Lines: 216752
Line Coverage: 96.34%
Relevant Branches: 52487
Covered Branches: 42633
Branch Coverage: 81.23%
Branches in Coverage %: No
Coverage Strength: 71.08 hits per line

💛 - Coveralls

Comment thread modules/pubstackBidAdapter.ts Outdated
Comment on lines +118 to +132
const enrichBidResponse = (adapterResponse, responseBody) => {
const rawBidsByImpId = mapResponseBidsByImpId(responseBody);

return {
...adapterResponse,
bids: (adapterResponse?.bids ?? []).map(bid => {
const rawBid = rawBidsByImpId.get(bid.requestId);
return {
...bid,
ttl: bid.ttl ?? rawBid?.ttl ?? rawBid?.exp ?? DEFAULT_TTL,
netRevenue: bid.netRevenue ?? rawBid?.netRevenue ?? DEFAULT_NET_REVENUE,
};
}),
};
};
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could do this using ortbConverter's bidResponse, something like

 bidResponse(buildBidResponse, bid, context) {
     return {
        ...buildBidResponse(bid, context),
        ttl: bid.ttl ?? bid.exp ?? DEFAULT_TTL,
        netRevenue: bid?.netRevenue ?? DEFAULT_NET_REVENUE,
     }
 }

which would make it considerably simpler & shorter, and also avoid the bot's concern. I'll note that neither ttl nor netRevenue are part of the ORTB spec and ortbConverter already uses exp when it finds it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, it is indeed much shorter

@sdeluce sdeluce requested a review from dgirardi April 8, 2026 06:43
Copy link
Copy Markdown
Collaborator

@lksharma lksharma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lksharma lksharma merged commit 4b3582a into prebid:master Apr 9, 2026
102 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants