Skip to content

Comments

Core: validate bid response mediaType against ad unit mediaTypes#14468

Open
anastasiiapankivFS wants to merge 2 commits intoprebid:masterfrom
anastasiiapankivFS:media-type-enforcement
Open

Core: validate bid response mediaType against ad unit mediaTypes#14468
anastasiiapankivFS wants to merge 2 commits intoprebid:masterfrom
anastasiiapankivFS:media-type-enforcement

Conversation

@anastasiiapankivFS
Copy link
Contributor

Type of change

  • Feature

Description of change

Reject bid responses whose mediaType does not match any of the ad unit's declared mediaTypes. This prevents mismatched bids (e.g. a video bid for a banner-only ad unit) from entering the auction.

#14459

Reject bid responses whose mediaType does not match any of the ad unit's
declared mediaTypes. This prevents mismatched bids (e.g. a video bid for
a banner-only ad unit) from entering the auction.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link

@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: 838e30cd96

ℹ️ 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 on lines +688 to +691
if (bid.mediaType) {
const mediaTypes = index.getMediaTypes(bid);
if (mediaTypes && Object.keys(mediaTypes).length > 0) {
if (!mediaTypes.hasOwnProperty(bid.mediaType)) {

Choose a reason for hiding this comment

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

P1 Badge Skip media-type guard when response omitted mediaType

This validation runs on prebidBid objects built via createBid(), which pre-populates mediaType as 'banner', so the if (bid.mediaType) guard is effectively always true in the adapter pipeline. As a result, adapters that legitimately omit mediaType in interpretResponse (for example modules/slimcutBidAdapter.js, which supports video but does not set mediaType) will now have video-only ad unit bids rejected here as banner mismatches, even though the new behavior is intended to skip validation when mediaType is unset.

Useful? React with 👍 / 👎.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@codex can you draft a fix

Choose a reason for hiding this comment

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

Codex couldn't complete this request. Try again later.

@patmmccann patmmccann linked an issue Feb 12, 2026 that may be closed by this pull request
@robertrmartinez
Copy link
Collaborator

do we consider this a breaking change?

I agree we should do this, but it is possible there are pubs handling and monetizing somehow on this.

Should we put it in a default off flag for now and remove option in Prebid 11?

@patmmccann

Also regarding IBV (faking banner but is video) this does not stop that, is there a plan to have something similar regarding mis-matching meta.mediaType?

Sorry I was unable to attend the PMC

@antoine-ga
Copy link

@robertrmartinez Regarding IBV, there was a change to bidResponseFilter that should addresses this. #14071
Now that I am looking at it, I have one question though, it checks bid.meta.mediaType against the ad unit's configured mediaTypes, not against bid.mediaType - do we foresee any issues with this, like with multi-format for example?

@patmmccann
Copy link
Collaborator

patmmccann commented Feb 12, 2026

#14071 intended to allow a publisher to turn off declared ibv responses on banner

This is about turning off video mediatypes (not ibv, but literal video responses) as responses on banner only units bc they simply won't render.

That being said, the 11 branch is open and if you think this breaks anyone we can target the pr at it to be safe

@robertrmartinez
Copy link
Collaborator

@antoine-ga
With aggressive filtering and throwing out of bids, I just think the best thing to do is always select a default but give users an option to change the behavior.

I can almost guarantee there is an integration out there where some bidder is responding with bidResponse.mediaType = video in a banner only prebid ad unit, and the pub has setup their adserver / on page code to handle it and render it accordingly.

And this would "break" that.

Now I really do not care if we merge with default on / off but just wanted to make sure we acknowledge!

@anastasiiapankivFS
Copy link
Contributor Author

Should we make media type enforcement configurable with default set to false, so we do not introduce breaking changes?

@patmmccann patmmccann changed the base branch from master to prebid-11.0 February 17, 2026 16:07
@patmmccann patmmccann changed the base branch from prebid-11.0 to master February 17, 2026 16:07
@patmmccann
Copy link
Collaborator

Should we make media type enforcement configurable with default set to false, so we do not introduce breaking changes?

let's just make the PR on the 11 branch to be safe instead since it's open and no need for config. Can you clean up failing tests and see the bot comment?

@patmmccann
Copy link
Collaborator

@anastasiiapankivFS i had codex prepare this pr on the 11 branch in the linked pr

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.

mediatype enforcement in core

4 participants