Openx bid adapter: WIP deduplicate request#14477
Openx bid adapter: WIP deduplicate request#14477marcin-wrobel-ox wants to merge 5 commits intoprebid:masterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors the OpenX bid adapter to consolidate multiple bid requests into a single HTTP request, improving performance by reducing network overhead. Previously, the adapter would send separate HTTP requests for video bids versus banner/native bids. With this change, all bid requests are combined into a single HTTP request with multiple impressions.
Changes:
- Simplified request building logic to create one HTTP request for all bid types
- Removed mediaType context parameter to allow ortbConverter to generate all media type objects in impressions
- Updated test expectations to validate single request with multiple impressions
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| modules/openxBidAdapter.js | Simplified buildRequests to return single consolidated request; removed helper functions for bid type detection and mediaType parameter |
| test/spec/modules/openxBidAdapter_spec.js | Updated tests to expect 1 request with multiple impressions instead of multiple requests; added mtype field to video response fixtures; added new tests for consolidated request behavior |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| crid: 'test-creative-id', | ||
| dealid: 'test-deal-id', | ||
| adm: '<VAST version="4.0"><Ad></Ad></VAST>', | ||
| mtype: 2, |
There was a problem hiding this comment.
The PR title indicates this is a "WIP" (Work In Progress). However, the code changes appear complete with proper test coverage. Please update the PR title to remove "WIP" if this is ready for review, or clarify what remaining work is needed before this can be merged.
|
|
||
| function buildRequests(bidRequests, bidderRequest) { |
There was a problem hiding this comment.
The simplified request consolidation now uses only the first bid request's parameters for request-level fields (platform, delDomain, coppa, doNotTrack, response_template_name, test - see lines 60-78 of the converter configuration). If different bid requests specify different values for these parameters, only the first request's values will be used. Consider validating that all bid requests have consistent request-level parameters, or document this limitation so publishers understand these parameters must be consistent across all ad units in an auction.
| function buildRequests(bidRequests, bidderRequest) { | |
| /** | |
| * Validate that all bidRequests use consistent values for request-level parameters. | |
| * The OpenRTB converter uses only the first bidRequest's values for these fields. | |
| * This function logs a warning when inconsistencies are detected so publishers are | |
| * aware that parameters must be consistent across all ad units in an auction. | |
| * | |
| * @param {Array} bidRequests | |
| */ | |
| function validateRequestLevelParamsConsistency(bidRequests) { | |
| if (!Array.isArray(bidRequests) || bidRequests.length < 2) { | |
| return; | |
| } | |
| const fields = ['platform', 'delDomain', 'coppa', 'doNotTrack', 'response_template_name', 'test']; | |
| const baseRequest = bidRequests[0] || {}; | |
| const baseParams = baseRequest.params || {}; | |
| for (let i = 1; i < bidRequests.length; i++) { | |
| const currentRequest = bidRequests[i] || {}; | |
| const currentParams = currentRequest.params || {}; | |
| fields.forEach(field => { | |
| if (baseParams[field] !== currentParams[field]) { | |
| utils.logWarn( | |
| `OpenX: inconsistent request-level parameter "${field}" between ad units. ` + | |
| 'The value from the first ad unit will be used for the OpenRTB request.' | |
| ); | |
| } | |
| }); | |
| } | |
| } | |
| function buildRequests(bidRequests, bidderRequest) { | |
| validateRequestLevelParamsConsistency(bidRequests); |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 719568da26
ℹ️ 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".
modules/openxBidAdapter.js
Outdated
| requests.push(createRequest([bid], bidderRequest, VIDEO)); | ||
| }); | ||
| return requests; | ||
| return [createRequest(bidRequests, bidderRequest)]; |
There was a problem hiding this comment.
Do not batch bids that need distinct request-level params
This change forces every OpenX bid into one ORTB request, but the request builder still reads coppa, doNotTrack, platform, delDomain, and response_template_name from only context.bidRequests[0]. As a result, when an auction contains multiple OpenX bids with different request-level params (for example different delDomain/platform or privacy flags), all non-first bids inherit the first bid’s settings; previously video bids were isolated into their own requests and kept their own params.
Useful? React with 👍 / 👎.
| method: 'POST', | ||
| url: config.getConfig('openxOrtbUrl') || REQUEST_URL, | ||
| data: converter.toORTB({bidRequests, bidderRequest, context: {mediaType}}) | ||
| data: converter.toORTB({bidRequests, bidderRequest}) |
There was a problem hiding this comment.
Keep mediaType context when converting video requests
Removing the context.mediaType argument from converter.toORTB means response parsing can no longer fall back to a known media type for video requests. In setResponseMediaType, if a bid response lacks seatbid.bid[].mtype (common in ORTB 2.5-style responses), the converter throws and the bid is skipped; this path was previously avoided by sending video requests with context.mediaType = 'video'.
Useful? React with 👍 / 👎.
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
Other information