Skip to content

Commit 6896fee

Browse files
authored
Core: allow vast xml without using cache (#14611)
* Core: allow vast xml without using cache * renaming
1 parent 6756249 commit 6896fee

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

src/video.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,12 @@ declare module './hook' {
131131
export const checkVideoBidSetup = hook('sync', function(bid: VideoBid, adUnit, videoMediaType, context, useCacheKey) {
132132
if (videoMediaType && (useCacheKey || context !== OUTSTREAM)) {
133133
// xml-only video bids require a prebid cache url
134-
const { url, useLocal } = config.getConfig('cache') || {};
134+
const { url, useLocal, allowVastXmlOnly } = config.getConfig('cache') || {};
135135
if ((!url && !useLocal) && bid.vastXml && !bid.vastUrl) {
136+
if (allowVastXmlOnly === true) {
137+
logWarn(`This bid contains only vastXml, and caching is disabled. Proceeding because cache.allowVastXmlOnly is enabled.`);
138+
return true;
139+
}
136140
logError(`
137141
This bid contains only vastXml and will not work when a prebid cache url is not specified.
138142
Try enabling either prebid cache with ${getGlobalVarName()}.setConfig({ cache: {url: "..."} });

src/videoCache.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ export interface CacheConfig {
7878
* Flag determining whether to locally save VAST XML as a blob
7979
*/
8080
useLocal?: boolean;
81+
/**
82+
* When true, allows VAST XML-only bids to pass even without cache.url or cache.useLocal.
83+
*/
84+
allowVastXmlOnly?: boolean;
8185
/**
8286
* Timeout (in milliseconds) for network requests to the cache
8387
*/

test/spec/video_spec.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { hook } from '../../src/hook.js';
33
import { stubAuctionIndex } from '../helpers/indexStub.js';
44
import * as utils from '../../src/utils.js';
55
import { syncOrtb2, validateOrtbFields } from '../../src/prebid.js';
6+
import { config } from 'src/config.js';
67

78
describe('video.js', function () {
89
let sandbox;
@@ -19,6 +20,7 @@ describe('video.js', function () {
1920

2021
afterEach(() => {
2122
utilsMock.restore();
23+
config.resetConfig();
2224
sandbox.restore();
2325
});
2426

@@ -284,6 +286,21 @@ describe('video.js', function () {
284286
expect(valid).to.equal(false);
285287
});
286288

289+
it('validates vastXml-only bids when cache.allowVastXmlOnly is enabled', function () {
290+
utilsMock.expects('logWarn').once();
291+
utilsMock.expects('logError').never();
292+
config.setConfig({ cache: { allowVastXmlOnly: true } });
293+
294+
const adUnits = [{
295+
adUnitId: 'au',
296+
bidder: 'vastOnlyVideoBidder',
297+
mediaTypes: { video: {} },
298+
}];
299+
300+
const valid = isValidVideoBid({ adUnitId: 'au', vastXml: '<xml>vast</xml>' }, { index: stubAuctionIndex({ adUnits }) });
301+
expect(valid).to.equal(true);
302+
});
303+
287304
it('validates valid outstream bids', function () {
288305
const bid = {
289306
adUnitId: 'au',

0 commit comments

Comments
 (0)