Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/video.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,12 @@ declare module './hook' {
export const checkVideoBidSetup = hook('sync', function(bid: VideoBid, adUnit, videoMediaType, context, useCacheKey) {
if (videoMediaType && (useCacheKey || context !== OUTSTREAM)) {
// xml-only video bids require a prebid cache url
const { url, useLocal } = config.getConfig('cache') || {};
const { url, useLocal, allowVastXmlOnly } = config.getConfig('cache') || {};
if ((!url && !useLocal) && bid.vastXml && !bid.vastUrl) {
if (allowVastXmlOnly === true) {
logWarn(`This bid contains only vastXml, and caching is disabled. Proceeding because cache.allowVastXmlOnly is enabled.`);
return true;
}
logError(`
This bid contains only vastXml and will not work when a prebid cache url is not specified.
Try enabling either prebid cache with ${getGlobalVarName()}.setConfig({ cache: {url: "..."} });
Expand Down
4 changes: 4 additions & 0 deletions src/videoCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ export interface CacheConfig {
* Flag determining whether to locally save VAST XML as a blob
*/
useLocal?: boolean;
/**
* When true, allows VAST XML-only bids to pass even without cache.url or cache.useLocal.
*/
allowVastXmlOnly?: boolean;
/**
* Timeout (in milliseconds) for network requests to the cache
*/
Expand Down
17 changes: 17 additions & 0 deletions test/spec/video_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { hook } from '../../src/hook.js';
import { stubAuctionIndex } from '../helpers/indexStub.js';
import * as utils from '../../src/utils.js';
import { syncOrtb2, validateOrtbFields } from '../../src/prebid.js';
import { config } from 'src/config.js';

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

afterEach(() => {
utilsMock.restore();
config.resetConfig();
sandbox.restore();
});

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

it('validates vastXml-only bids when cache.allowVastXmlOnly is enabled', function () {
utilsMock.expects('logWarn').once();
utilsMock.expects('logError').never();
config.setConfig({ cache: { allowVastXmlOnly: true } });

const adUnits = [{
adUnitId: 'au',
bidder: 'vastOnlyVideoBidder',
mediaTypes: { video: {} },
}];

const valid = isValidVideoBid({ adUnitId: 'au', vastXml: '<xml>vast</xml>' }, { index: stubAuctionIndex({ adUnits }) });
expect(valid).to.equal(true);
});

it('validates valid outstream bids', function () {
const bid = {
adUnitId: 'au',
Expand Down
Loading