Skip to content

Run Open Measurement verification scripts declared in VAST wrappers - #1067

Open
postindustria-code wants to merge 2 commits into
prebid:masterfrom
postindustria-tech:fix/vast-wrapper-ad-verifications
Open

postindustria-code wants to merge 2 commits into
prebid:masterfrom
postindustria-tech:fix/vast-wrapper-ad-verifications

Conversation

@postindustria-code

@postindustria-code postindustria-code commented Nov 30, 2026 •

Copy link
Copy Markdown
Collaborator

Why: AdVerifications were read from the InLine ad only, so a verification vendor added by a VAST Wrapper was never measured.

What changed

  • Verification scripts are collected along the whole wrapper chain and deduplicated.
  • A video ad without usable verification scripts skips the OM session with a debug log, instead of logging an error on every OM event.
  • A verification script without a vendor or parameters is loaded without parameters instead of being dropped.
  • One invalid script no longer fails the session for the other vendors.
  • Empty <AdVerifications/> nodes and extensions are ignored, so they no longer hide an extension that has scripts.

Tested: :PrebidMobile-core:testDebugUnitTest, with new cases in AdResponseParserVastTest and OmAdSessionManagerTest (previously an empty placeholder). MraidInternalBrowserActionTest fails on master without this change as well.

iOS counterpart: prebid/prebid-mobile-ios#1457

AdVerifications were read from the InLine ad only, so a verification
vendor added by a Wrapper was never measured. Scripts are now collected
along the whole wrapper chain and deduplicated.

A video ad without verification scripts skips the OM session with a
debug log instead of an error on every event, and a script without a
vendor or parameters is loaded without parameters rather than failing
the session for all vendors.
The "no scripts" check ran before unusable scripts were dropped, so an ad
whose every script was invalid still got an OM session with no scripts,
and its later OM calls logged errors. The scripts are now converted first
and the session is skipped when none is left.

An empty <AdVerifications/> node also hid an Extension that had scripts;
empty nodes and extensions are now ignored. "Using jsResource" is logged
only for the scripts that are used.

OmAdSessionManagerTest was an empty placeholder. It now checks how
verification scripts become OM resources (with and without vendor or
parameters, malformed or missing URLs), that an ad with no usable scripts
skips the session with debug logs only, that a missing session without
that skip still logs an error, and that the next ad with scripts clears
the skip flag.
@YuriyVelichkoPI

Copy link
Copy Markdown
Contributor

This PR might solve the issue #1066

@YuriyVelichkoPI YuriyVelichkoPI added this to the 3.5.0 milestone Nov 30, 2026

@YuriyVelichkoPI YuriyVelichkoPI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks, this closes #1066 nicely. Wrapper <AdVerifications> and wrapper Extensions are now read, the chain is merged and deduplicated, and the OM changes are a real improvement: one bad script no longer disables every vendor, and scripts without parameters still load. For InLine-only responses with valid scripts the OM script list is unchanged. CI is green, and the new tests plus the video/loading suites pass locally.

Please apply the changes below once #1034 is merged, and rebase onto it. #1034 changes how the played ad is selected (adIndex can now be greater than 0) and adds getAdIndex(parser, index), which returns the followed Wrapper ad for wrapper responses and the played ad for the last response. This PR has to build on that. Without it, the two PRs merge without a git conflict in AdResponseParserVast.java, but the wrapper scripts get dropped again (see 1).

  1. Use the right ad at each level of the chain (inline on AdResponseParserVast.java). The loop reads ad index in every response, not the Wrapper ad that getVastUrl() actually followed.

    • On its own, a multi-ad wrapper response runs a script from an ad that's never shown and skips the followed Wrapper's script.
    • On top of #1034, adIndex = 1 makes a single-ad wrapper response return null, so the wrapper vendor is silently dropped. That's #1066 again.

    After rebasing, use #1034's getAdIndex(parser, index) in the loop and pass adIndex from CreativeModelsMakerVast, as #1066 suggested.

  2. Add a test for the wiring in CreativeModelsMakerVast (inline). If line 116 is reverted to master, every test still passes. Please add a test through makeModels that asserts both the wrapper and the InLine vendor, plus a case where the played ad isn't ad 0 (and the followed Wrapper isn't ad 0).


Ad ad = parserVast.vast.getAds().get(index);
for (AdResponseParserVast parser = parserVast; parser != null; parser = parser.wrappedVASTXml) {
AdVerifications adVerifications = getOwnAdVerifications(parser, index);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This uses the same index in every response of the chain. In a wrapper response, though, the ad that matters is the Wrapper that getVastUrl() followed (the first one with a VASTAdTagURI), not ad index.

Once #1034 is merged, please rebase and use its lookup here:

AdVerifications adVerifications = getOwnAdVerifications(parser, getAdIndex(parser, index));

With that on #1034 + this PR, both cases give followedWrapper, …, and the existing suites (including #1034's tests) stay green.

final String videoDuration = latestVastWrapperParser.getVideoDuration(latestVastWrapperParser, 0);
final String skipOffset = latestVastWrapperParser.getSkipOffset(latestVastWrapperParser, 0);
final AdVerifications adVerifications = rootVastParser.getAdVerification(latestVastWrapperParser, 0);
final AdVerifications adVerifications = rootVastParser.getAdVerification(rootVastParser, 0);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This line is what actually turns the feature on, but no test covers it. With it reverted to master's getAdVerification(latestVastWrapperParser, 0), all rendering.* tests and OmAdSessionManagerTest still pass (282 green).

After rebasing on #1034 this becomes rootVastParser.getAdVerification(rootVastParser, adIndex). Please add tests in CreativeModelsMakerVastTest that go through makeModels:

  • A wrapper chain with a wrapper-level <AdVerifications> (for example, extend the testMakeModelsWrapper fixture or a copy of it). Assert that model.getAdVerifications() contains both the wrapper vendor and the InLine vendor.
  • A case where the played ad isn't ad 0 (adIndex > 0) and the followed Wrapper isn't ad 0. Assert that only the followed Wrapper's and the played InLine's vendors are present.

@mdanylov-sigma mdanylov-sigma left a comment

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.

I agree with Yuriy's review (the per-level ad index after rebasing on #1034, and the makeModels wiring test), so I won't repeat those. There's one more issue this PR introduces, inline below.

Older gaps in the OM verification handling are tracked in #1068, so they don't block this PR. Wrapper scripts now reach them too: non-OMID resources, Extensions ignored next to a non-empty node, parameters dropped without a log when vendor is missing, and verificationNotExecuted.

}
for (Verification verification : adVerifications.getVerifications()) {
// The same script is often repeated along the chain; running it twice would double count.
String key = verification.getVendor() + '|' + verification.getJsResource()

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.

The key is built from the raw fields, but createVerificationScriptResources maps every entry with an empty vendor or empty parameters to createVerificationScriptResourceWithoutParameters(url). So entries that OM will receive as the same resource can still have different keys:

  • a missing <VerificationParameters> (null) and an empty <VerificationParameters/> ("", since readText returns an empty string)
  • the same script with and without a vendor attribute, when it has no parameters

Example: Wrapper <Verification vendor="dv"><JavaScriptResource>https://x/omid.js</JavaScriptResource></Verification>, and InLine with the same entry plus <VerificationParameters/>. The keys dv|https://x/omid.js|null and dv|https://x/omid.js| differ, so both become WithoutParameters(https://x/omid.js). The OM service script gives every resource its own iframe (omid-verification-script-frame-<id> in omsdk.js), so the script really runs twice. That's the double count the comment above says this prevents.

Could the key be built from what OM gets? For example, dedupe in createVerificationScriptResources after the mapping:

boolean withParameters = !TextUtils.isEmpty(vendorKey) && !TextUtils.isEmpty(params);
String key = url + "|" + (withParameters ? vendorKey + "|" + params : "");
if (!seen.add(key)) {
    continue;
}

Or keep it in the parser, but treat null and "" the same and leave the vendor out of the key when there are no parameters. A test with the null/empty pair would cover it.

This branch has not been deployed

No deployments
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.

3 participants