Repository navigation
Allow consented first-party relay auctions under TCF - #1498
ChristianPavilonis wants to merge 6 commits into
Conversation
aram356
left a comment
There was a problem hiding this comment.
Please make softVendorExceptions be config This should on for testing TS
|
Addressed in f22a83f. Added |
|
Included the current feature delta from this PR at The baseline replay reproduced the known automatic-CMP ownership regression with the testing flag explicitly enabled: a later publisher denial plus stale CMP grant produced a stubbed identity request/cookie. Port #1545 carries the existing guarded-setter correction and normal/deferred/throwing-subscriber regressions; this extra correction is not claimed present on this source branch. The default-off/testing-only setting and Purpose2/GVL controls remain unchanged. The port's45 focused artifact/consent cases and180 Rust Prebid cases pass, as do31 broader local gates and a fresh container smoke. Hosted checks for the port/advanced RC are pending; no deployment or production privacy acceptance is claimed. |
aram356
left a comment
There was a problem hiding this comment.
Summary
This round makes the relay basic-ads soft vendor exception an explicit testing opt-in (integrations.prebid.relay_soft_vendor_exception, default off), as requested last round. The config plumbing, the default, and the Prebid Purpose 2 and GVL-mapping enforcement hold up. One blocking issue remains: with the flag on and managed User IDs configured, the relay rule write breaks the shim's automatic CMP ownership handoff, and a later publisher GDPR denial can be overridden by a CMP grant.
1 of the inline comments below carries a one-click GitHub
suggestion. Use Commit suggestion to apply it as a commit on the PR branch. The other comments describe the fix in prose because the change touches multiple files or lines outside the diff and can't be auto-applied.
Blocking
🔧 wrench
- Relay rule writes go through the managed-ID ownership wrapper: see inline at
crates/trusted-server-js/lib/src/integrations/prebid/index.ts:2487 - Two CI checks failed: see Cross-cutting below
Non-blocking
🤔 thinking / ⛏ nitpick / 📝 note
- 🤔 Leave the key out of the template: see inline at
trusted-server.example.toml:533 - ⛏ Keep the measured sizes in the budget comment: see inline at
crates/trusted-server-js/lib/test/prebid-artifact-integration.test.mjs:415 - ⛏ Configuration reference and CHANGELOG: see Cross-cutting below
- 📝 Description bullet with no code change: see Cross-cutting below
Cross-cutting / body-level findings
- 🔧 Two CI checks failed:
browser integration testsandtrace runtime and browser acceptanceboth failed while installing browser packages (Temporary failure resolving 'azure.archive.ubuntu.com'), before any test ran. Neither is required by branch protection, and the cause is the runner's apt mirror, not this diff. Please re-run both once the mirror recovers. - ⛏ Configuration reference and CHANGELOG: the Prebid browser-field table in
docs/guide/configuration.md(around line 2005) is the full configuration reference but has norelay_soft_vendor_exceptionrow; only the integration guide was updated.CHANGELOG.md[Unreleased]also has noAddedentry for the key. That entry is the place to say it is testing-only, defaults to false, and is rejected by older binaries, so it must be removed before a rollback. - 📝 Description bullet with no code change: "Forward original consent signals to downstream auction endpoints" describes existing server behavior; nothing in this diff changes forwarding. The claim itself holds:
/auctionfails closed on TCF Purpose 1 for GDPR traffic and forwards the TC string to PBS.
CI Status
- Analyze (actions): PASS
- Analyze (javascript-typescript): PASS
- Analyze (python): PASS
- Analyze (rust): PASS
- browser integration tests: FAIL
- cargo check (cloudflare native + wasm32-unknown-unknown): PASS
- cargo check/build/test (spin native + wasm32-wasip1): PASS
- cargo fmt: PASS (required)
- cargo test: PASS (required)
- cargo test (axum native): PASS
- cargo test (cross-adapter parity): PASS
- cargo test (ts CLI, native) (macos-latest): PASS
- cargo test (ts CLI, native) (ubuntu-latest): PASS
- CI Node pin guard: PASS
- CLAUDE.md symlink guard: PASS
- CodeQL: PASS
- docs-proposal scripts: PASS
- format-docs: PASS (required)
- format-typescript: PASS (required)
- HTML EOF runtime (Fastly): PASS
- integration tests: PASS
- integration tests (Fastly EC lifecycle): PASS
- prepare integration artifacts: PASS
- release scripts: PASS
- trace runtime and browser acceptance: FAIL
- ts dev lint domains (changed lines): PASS
- vitest: PASS
- worker-deadlines (cloudflare): PASS
- worker-deadlines (spin): PASS
prk-Jr
left a comment
There was a problem hiding this comment.
Summary
The default-off configuration plumbing and Purpose 2/vendor-mapping controls hold up. I independently reproduced the existing managed-ID consent ownership blocker at f22a83fce; no additional runtime defects found.
No one-click suggestions are included: the consent correction requires changes outside the diff and combined lifecycle tests.
Blocking
- 🔧 P1 — Relay updates can override a later publisher denial — see inline at
crates/trusted-server-js/lib/src/integrations/prebid/index.ts:2487. - 🔧 Two CI gates need successful reruns —
browser integration testsandtrace runtime and browser acceptancefailed during browser dependency installation with Ubuntu mirror DNS errors. These are infrastructure failures, but browser acceptance remains unverified. Neither check is required by branch protection; both remain applicable repository gates.
Non-blocking
- ⛏ Configuration reference and rollback guidance — document
relay_soft_vendor_exceptionin the configuration reference and explain rollback compatibility: older binaries reject even an explicitfalse. Existing configurations that omit the key remain compatible.
Verification
All seven changed files and affected consumers were reviewed. Under pinned Node 24.20.0, 45 existing focused relay/artifact/consent tests passed, with no type errors. A separate production-artifact JSDOM probe reproduced an identity request and idl_env cookie after publisher denial with the flag enabled; its flag-disabled control passed. Rust suites were assessed through hosted CI, not rerun locally. No live deployment verification was performed.
CI Status
- trace runtime and browser acceptance: FAIL
- integration tests: PASS
- browser integration tests: FAIL
- integration tests (Fastly EC lifecycle): PASS
- CodeQL: PASS
- cargo check/build/test (spin native + wasm32-wasip1): PASS
- CLAUDE.md symlink guard: PASS
- Analyze (actions): PASS
- worker-deadlines (spin): PASS
- ts dev lint domains (changed lines): PASS
- cargo test (ts CLI, native) (macos-latest): PASS
- cargo test (ts CLI, native) (ubuntu-latest): PASS
- docs-proposal scripts: PASS
- cargo test: PASS (required)
- cargo fmt: PASS (required)
- prepare integration artifacts: PASS
- cargo check (cloudflare native + wasm32-unknown-unknown): PASS
- cargo test (cross-adapter parity): PASS
- Analyze (javascript-typescript): PASS
- cargo test (axum native): PASS
- format-docs: PASS (required)
- vitest: PASS
- HTML EOF runtime (Fastly): PASS
- format-typescript: PASS (required)
- release scripts: PASS
- CI Node pin guard: PASS
- worker-deadlines (cloudflare): PASS
- Analyze (rust): PASS
- Analyze (javascript-typescript): PASS
- Analyze (python): PASS
There was a problem hiding this comment.
Superseded by a follow-up review with inline comments: #1498 (review)
dhruv8sh
left a comment
There was a problem hiding this comment.
Summary
Adds an opt-in integrations.prebid.relay_soft_vendor_exception flag (default false) that lets the Prebid shim add trustedServer to the basicAds soft vendor exceptions before relay auctions. The guard is idempotent, keeps Purpose 2 and publisher GVL mappings enforced, and Prebid's per-purpose defaults keep the storage rule in place when the shim adds a basicAds rule. The code looks right; the only blocker is two browser CI jobs that failed on runner infrastructure.
1 of the inline comments below carries a one-click GitHub
suggestion— use Commit suggestion to apply it as a commit on the PR branch.
Blocking
🔧 wrench
- Two browser CI jobs failed — see cross-cutting below
Non-blocking
🤔 thinking / ⛏ nitpick
- "Closes #1497" overstates the fix — see cross-cutting below
- Keep the running size breakdown when raising the shim guard — see inline at
crates/trusted-server-js/lib/test/prebid-artifact-integration.test.mjs:412
Cross-cutting / body-level findings
- 🔧 Two browser CI jobs failed —
browser integration testsandtrace runtime and browser acceptancefailed (neither is in the required set). Both logs showTemporary failure resolving 'azure.archive.ubuntu.com'while installing Playwright browser dependencies, so this looks like a runner DNS problem, not this diff. Please re-run them. - 🤔 "Closes #1497" overstates the fix — The flag defaults to
falseand is documented as a testing-only opt-in, so a production deployment that merges this still sees relay auctions blocked under GDPR, which is what #1497 reports. Consider "Refs #1497" (and a title like "Add an opt-in relay soft vendor exception for TCF testing") so the issue stays open until there is a production consent path, such as a publisher-configured relay GVL identity.
CI Status
- cargo test: PASS (required)
- cargo fmt: PASS (required)
- format-docs: PASS (required)
- format-typescript: PASS (required)
- vitest: PASS
- Analyze (rust), Analyze (javascript-typescript), Analyze (python), Analyze (actions), CodeQL: PASS
- cargo test (axum native), cargo test (cross-adapter parity), cargo test (ts CLI, native) (ubuntu-latest / macos-latest): PASS
- cargo check (cloudflare native + wasm32-unknown-unknown), cargo check/build/test (spin native + wasm32-wasip1): PASS
- worker-deadlines (cloudflare / spin), HTML EOF runtime (Fastly): PASS
- integration tests, integration tests (Fastly EC lifecycle), prepare integration artifacts: PASS
- ts dev lint domains (changed lines), release scripts, docs-proposal scripts, CI Node pin guard, CLAUDE.md symlink guard: PASS
- browser integration tests: FAIL
- trace runtime and browser acceptance: FAIL
Route relay soft vendor exception updates through the active automatic IAB consent owner so they do not retire it or open an unguarded CMP subscription. Add combined managed-ID relay regressions, keep the setting out of the example config, and document it in the configuration reference and changelog.
|
Review round addressed in 33ce161, merged with current
Checks after the merge: full native core suite (3,399 passed), CLI suite (963 passed), focused relay/artifact/consent JS tests (369 passed), Rust and docs formatting. The full JS suite (3,319 tests), ESLint and Prettier passed before the merge, which changed no JavaScript. Adapter, Clippy and browser jobs are left to CI. |
dhruv8sh
left a comment
There was a problem hiding this comment.
Summary
This PR adds a testing-only integrations.prebid.relay_soft_vendor_exception flag. When it is on, the Prebid shim adds trustedServer to the basicAds rule's softVendorExceptions before each relay auction. It also sends the relay's rule writes through the automatic-CMP guard. The Rust flag wiring, the docs and the rollback note are clean, and the flag defaults to off. The problem is how the shim builds its rules array. Prebid's tcfControl treats any explicit gdpr.rules array as a full replacement for its defaults. So the guard changes enforcement for things other than the relay: it drops Purpose 1 storage enforcement in the common no-rules case, and it adds a Purpose 2 vendor gate on top of publisher rule sets that deliberately left one out. Both go against the documented promise that "storage, and User ID modules keep their existing rules".
The inline comments describe their fixes in prose. Each fix also needs changes to the unit tests in
relay_consent.test.ts, which currently assert the faulty output, so neither can be applied as a one-clicksuggestion.
Blocking
🔧 wrench
- Seeding
ruleswith onlybasicAdsdrops Prebid's default Purpose 1 (storage) enforcement: see inline atcrates/trusted-server-js/lib/src/integrations/prebid/relay_consent.ts:38 - Adding a
basicAdsrule to publisher rule sets that left it out tightens P2 vendor enforcement for every other bidder: see inline atcrates/trusted-server-js/lib/src/integrations/prebid/relay_consent.ts:57
Non-blocking
🤔 thinking
- Relay rule writes subscribe through the
__tcfapicaptured at activation, which may be stale: see inline atcrates/trusted-server-js/lib/src/integrations/prebid/index.ts:860
👍 praise
- The end-to-end artifact matrix checks real
tcfControldecisions (flag unset/false/true, P2 denied, GVL-mapped) against the actual bundle: see inline atcrates/trusted-server-js/lib/test/prebid-artifact-integration.test.mjs:332
| // An operator-supplied vendor identity keeps its vendor-consent gate. | ||
| if (mapped && !addedException) return; | ||
|
|
||
| const rules: unknown[] = gdpr.rules ?? []; |
There was a problem hiding this comment.
🔧 wrench: Seeding rules with only basicAds turns off Prebid's default Purpose 1 (storage) enforcement.
In Prebid's tcfControl, setEnforcementConfig uses DEFAULT_RULES only when gdpr.rules is absent. DEFAULT_RULES is both { purpose: 'storage', enforcePurpose: true, enforceVendor: true } and { purpose: 'basicAds', … }. Any explicit array fully replaces that default: purpose1Rule = rules['storage'] becomes undefined.
The most common publisher config is consentManagement.gdpr = { cmpApi: 'iab' } with no rules. This is also exactly what the automatic managed-User-ID activation writes. In that case this line starts from [], the branch at line 57 pushes only a basicAds rule, and the resulting setConfig silently removes device-access enforcement for every bidder, User ID module and analytics adapter on the page. A guard that is meant to relax one vendor check for one bidder ends up dropping a whole consent gate. That contradicts the docs ("storage, and User ID modules keep their existing rules").
The unit test retains both default basic-ads gates and is idempotent (relay_consent.test.ts:37-49) encodes the bug: it expects rules to contain only the basicAds entry.
Proposed fix (apply manually: the test expectation in relay_consent.test.ts must change with it, so this can't be a single-file suggestion):
// Without explicit rules Prebid enforces both default rules. Writing any
// `rules` array replaces those defaults, so materialise both before
// adding the relay exception.
const rules: unknown[] = gdpr.rules ?? [
{ purpose: 'storage', enforcePurpose: true, enforceVendor: true },
{ purpose: 'basicAds', enforcePurpose: true, enforceVendor: true },
];Then update the idempotency test to expect both the storage rule and the basicAds rule with softVendorExceptions: ['trustedServer']. Also add an artifact-level assertion that a Purpose-1-denied page still blocks storage after a relay auction.
| }; | ||
| }); | ||
|
|
||
| if (!foundBasicAds && !mapped) { |
There was a problem hiding this comment.
🔧 wrench: Adding a basicAds rule to a publisher's custom rule set adds a Purpose 2 vendor gate the publisher left out on purpose.
When a publisher passes an explicit rules array with no basicAds entry (for example only storage), tcfControl does not enforce Purpose 2 for anyone. The comment "Custom rules replace Prebid's defaults, so retain both default gates" has this backwards: the publisher's custom rules are the full policy. Pushing { purpose: 'basicAds', enforcePurpose: true, enforceVendor: true } therefore adds P2 purpose and vendor enforcement for every client-side bidder on the page. Bidders that were allowed before can now be blocked in tcf2Enforcement. That breaks the docs' promise that "unrelated bidders … keep their existing rules". It is also unnecessary: with no basicAds rule, trustedServer is not blocked by P2 in the first place.
With the line 38 fix (seed both defaults when rules is absent), every case that needs an exception already contains a basicAds rule. This branch can then go away completely:
// An explicit rule set without `basicAds` does not enforce Purpose 2 for
// any bidder, so the relay needs no exception and the publisher's
// policy is left untouched.(Apply manually. Removing this branch alone, without the line 38 change, would leave the default no-rules case blocked. Add a unit test showing that rules: [{ purpose: 'storage', … }] produces no setConfig call.)
| } finally { | ||
| if (tcfWindow.__tcfapi === guardedTcfApi) tcfWindow.__tcfapi = originalTcfApi; | ||
| } | ||
| activation.applyConfig = (value) => { |
There was a problem hiding this comment.
🤔 thinking: applyConfig now runs on every relay rule write, not only once at activation. Each consentManagement write makes Prebid's consent module re-run its IAB lookup, so a new addEventListener call goes out through guardedTcfApi. guardedTcfApi always forwards to the originalTcfApi captured when the automatic owner activated.
A common CMP pattern installs a __tcfapi stub first and later replaces it with the full implementation. If that swap happens between activation and the first relay auction, Prebid's new subscription goes to the old stub function. That stub may push onto a queue the real CMP has already drained, so the callback never fires and the auction waits out the consent timeout. Before this PR there was only one guarded subscription, made at activation time, so this window didn't exist.
One option: when previousTcfApi is not guardedTcfApi and differs from originalTcfApi, build the per-call guard over previousTcfApi, or skip the guard and use plain setConfig. That keeps the stale-listener cleanup bound to the API that accepted the subscription, as the existing comment intends. It would be worth a test that swaps window.__tcfapi between runGdprPage's activation and the relay auction.
| } | ||
|
|
||
| describe('tsjs-prebid production artifacts', () => { | ||
| it.each([ |
There was a problem hiding this comment.
👍 praise: Running the real production bundle across flag unset/false/true, Purpose 2 denied and a GVL-mapped relay, and asserting on tcf2Enforcement.biddersBlocked, is the right level for this change. It proves the exception actually changes what Prebid decides, not only that a config object was written. Checking that rubicon stays blocked in every case is also a good guard against the exception spreading to other bidders.
prk-Jr
left a comment
There was a problem hiding this comment.
Summary
Re-review at b08647a4f. The managed-ID ownership finding from my previous review is fixed: relay rule writes now go through the automatic consent owner, and the subscription they create keeps the callback guard. The flag defaults to off and stays testing-only, and Purpose 2 and publisher GVL mappings are still enforced. Approving.
Non-blocking
⛏ nitpick
- The comment on the added
basicAdsrule describes Prebid's defaults wrongly: see inline atcrates/trusted-server-js/lib/src/integrations/prebid/relay_consent.ts:58
📝 note
- Prebid 10.26 does not drop default rules when
gdpr.rulesis set (this concerns @dhruv8sh's two wrench findings onrelay_consent.ts:38and:57). At the lockedprebid.js10.26.0,setEnforcementConfigmaps the explicit array by purpose and then assignsACTIVE_RULES[...] = rules[name] ?? opts.defaultfor every configurable purpose (modules/tcfControl.ts:389-398; the builtdist/src/modules/tcfControl.js:318is the same). A rule set with onlybasicAdstherefore still enforces the defaultstorage,personalizedAdsandmeasurementrules. A publisher rule set withoutbasicAdsstill gets the default Purpose 2 gate, so the pushed entry matches that default plus the relay's soft exception and does not tighten other bidders. I checked this against the production artifact: with the flag on, Purpose 1 denied and no publisher rules, the relay writesrules: [basicAds only], andrubiconis still inufpdBlocked. That is the Purpose 4 default rule, which would vanish if an explicit array replaced the defaults. The "replace the defaults" behavior is how older Prebid releases worked. So I don't think either change is needed at this version; only the code comment is misleading (inline above). - @dhruv8sh's 🤔 about the
__tcfapicaptured at activation going stale before a later relay write is still open. I agree it's worth a follow-up test and didn't repeat it.
Verification
- Focused tests:
relay_consent,prebid-artifact-integrationandprebid-consent-enforcementpass (50 tests, no type errors), under Node 24.12.0; the repository pins 24.20.0. - Negative control: sending relay writes through the unguarded
originalSetConfig, even with the automatic owner active, makes both deferred-CMP takeover regressions fail. The guard is what keeps the publisher's denial in place. - The suggestion passes Prettier, ESLint and the
relay_consentunit tests, and changes only the comment. - Rust and docs changes were read in full; the Rust test covers omitted, false and true, with the plan both enabled and disabled.
CI Status
All 30 checks pass at b08647a4f, including browser integration tests, trace runtime and browser acceptance, vitest, cargo test, cargo fmt (which also runs clippy), format-typescript and format-docs.
| }); | ||
|
|
||
| if (!foundBasicAds && !mapped) { | ||
| // Custom rules replace Prebid's defaults, so retain both default gates. |
There was a problem hiding this comment.
⛏ nitpick: This comment says custom rules replace Prebid's defaults. At the locked Prebid 10.26.0 they don't: setEnforcementConfig falls back to opts.default for every purpose the explicit array omits (tcfControl.ts:397). So the default storage gate is still in force, and this entry matches the default basicAds gate with only the relay exception added. A reader who trusts the current wording could "fix" the guard to seed rules that Prebid already applies.
| // Custom rules replace Prebid's defaults, so retain both default gates. | |
| // tcfControl falls back to each purpose's default rule when an explicit | |
| // rule set omits it, so this entry matches the default basic-ads gate | |
| // and only adds the relay exception. |
Summary
With GDPR applicable and Purpose 2 consent granted, Prebid can block
trustedServerbefore calling/auctionbecause the first-party relay has no GVL vendor identity. This PR makes the relay's basic-ads soft vendor exception an explicit testing opt-in rather than applying it to every deployment.integrations.prebid.relay_soft_vendor_exception, defaulting tofalse, and inject it aswindow.__tsjs_prebid.relaySoftVendorException.trustedServerto thebasicAdsrule'ssoftVendorExceptionsbefore relay auctions. Keep Purpose 2 enforcement, unrelated bidders' consent checks, publisher rules, and publisher-supplied GVL identity enforcement.Existing behavior, unchanged here:
/auctionforwards the original consent signals, and downstream auction endpoints remain responsible for individual vendor enforcement.Deployment setting
Production deployments should omit the setting, which means false. Set it to
trueonly to opt into the relay exception for testing:Binaries built before this PR reject the key, even when it is set to
false, so remove it from the stored configuration before rolling back. Without an appropriate publisher-configured relay GVL identity or exception, normal TCF vendor enforcement can still block relay auctions. This option does not set Prebid Server'stest_modeor make traffic non-billable. No production deployment configuration was changed by this PR.Changes
true, and routes its rule updates through the automatic CMP owner when one is active.ts config initoutput stays loadable by older binaries.Verification
After the review fixes and
mainmerge (b08647a4f):At
f22a83fce, before the review fixes:The earlier live Chrome reproduction showed that temporarily applying the source guard restored
/auctionrequests without changing CMP consent.Closes #1497.