Skip to content

Turn off creative and auction endpoints when their switch is off - #1675

Draft
aram356 wants to merge 20 commits into
mainfrom
prfection/1669-creative-endpoint-gating-plan
Draft

aram356 wants to merge 20 commits into
mainfrom
prfection/1669-creative-endpoint-gating-plan

Conversation

@aram356

@aram356 aram356 commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

PRfection phase: implementation

Closes #1669

Summary

When a switch is off, the endpoint it controls now answers a local 404 with Cache-Control: no-store, private, on every adapter:

Endpoint Answers while
GET /first-party/proxy [auction].rewrite_creatives = true
GET, POST /first-party/sign [auction].rewrite_creatives = true
GET /first-party/click rewrites_auction_clicks() (rewrite_clicks, or rewrite_creatives when it is unset)
GET, POST /first-party/proxy-rebuild same as /first-party/click
POST /auction [auction].enabled = true

Until now the Prebid shim added a trustedServer bid to every ad unit whatever [auction].enabled said. The server now tells it, through a new auctionEnabled flag in the injected config, when the auction is off. The shim then drops that bid and its bid adapter builds no request, so a disabled auction sends no POST /auction, including through a publisher alias of trustedServer.

This PR holds the spec, the plan and the implementation. The spec and plan were first opened here for review on their own, and the implementation follows the plan task by task.

Documents

Implementation

  • http_util::endpoint_turned_off_response builds the turned-off answer:

    • status 404, body This endpoint is turned off, Content-Type: text/plain; charset=utf-8;
    • Cache-Control: no-store, private plus the terminal-private marker;
    • one debug log line.
  • The five core handlers check their switch as their first statement and return that answer as Ok:

    • handle_first_party_proxy, handle_first_party_proxy_sign, handle_first_party_click and handle_first_party_proxy_rebuild in proxy.rs;
    • handle_auction in auction/endpoints.rs, where the check replaces the old disabled no-bid branch.

    The only adapter dispatch change is Fastly's /auction arm, which sets its EID sync source and builds its partner registry only while the auction is on, so a turned-off request writes no EIDs.

  • Proxy finalization runs the creative HTML and CSS pass only while rewrite_creatives = true. Proxy callers that do not stream, such as the Google Tag Manager integration, pass HTML and CSS through unchanged while it is off, instead of writing URLs for turned-off endpoints.

  • The Prebid head injector adds auctionEnabled from the compiled auction plan. While it is false, the shim leaves no trustedServer bid in any ad unit, and the adapter's buildRequests returns [], which also covers aliases. Its ad-unit selection now matches Prebid's requestBids: adUnitCodes: [] selects every global ad unit, a single code string narrows to that code, and adUnitCodes narrows explicit adUnits.

  • Docs and CHANGELOG.md. One Breaking entry and one Fixed entry. The docs warn that creatives already on a page stop loading proxied assets or redirecting clicks once their switch is off. The trusted-server.example.toml comments say what each switch turns off.

Two changes go beyond the plan:

  • auction_rewrite_setting_does_not_change_proxied_html_or_css_rewriting was kept, then replaced. The plan said to delete it. It was kept because the Google Tag Manager integration proxies without streaming and still ran the creative pass whatever rewrite_creatives said. Review round 1 made that pass follow rewrite_creatives, and the test became creative_rewriting_off_passes_proxied_html_and_css_through_unchanged.
  • The Prebid shim size guard in prebid-artifact-integration.test.mjs moves from 52,500 to 52,750 characters. The shim now measures 52,549 characters, which leaves 201 to spare. The guard still fails if Prebid's 200 KB runtime gets bundled.

Tests

  • Core.
    • Every switch combination for the four creative endpoints, including correctly signed URLs, which still get the 404.
    • /auction answers the 404 on an unparseable body and on an over-limit Content-Length, with no telemetry and no trace.
    • The two trace tests that used a disabled auction now use an enabled auction with consent denied, and keep their policy_skipped assertions.
  • Adapters.
    • turned_off_endpoints_answer_404_locally on Fastly, Axum, Cloudflare and Spin checks status, body, Content-Type and Cache-Control. On Fastly it also checks the terminal-private marker.
    • each_switch_turns_off_only_its_own_endpoints on all four runs the default auction config and enabled = true with rewrite_creatives = false, so each 404 is traced to its own switch.
    • turned_off_auction_is_not_eligible_for_eid_persistence on Fastly.
  • Fastly send boundary.
    • late_filter_effects_cannot_make_a_turned_off_response_public covers late request-filter changes to Cache-Control.
    • A request filter that answers first still wins over a turned-off POST /auction.
  • Parity. turned_off_endpoints_parity and each_switch_turns_off_only_its_own_endpoints_parity send the same requests to Axum, Cloudflare and Spin.
  • Prebid.
    • Rust checks auctionEnabled true and false.
    • Vitest covers both shim states, adUnitCodes selection, adUnitCodes: [], aliases and GPT refresh.
    • The production-artifact test runs real Prebid with auctionEnabled: false and a trustedServer alias, and sees no /auction request. Its control without the flag sees one.
  • Mutation checks. Each new test was shown to fail with the behaviour it guards removed. The switch-isolation tests fail on all five suites when /first-party/proxy is gated on auction.enabled or /auction on rewrite_creatives.

Review round 1

Review 6101293433 raised four should-fix findings and six nits at 468873720. 3ce2d715b fixes all ten, and each thread has a reply with its evidence. Two of the fixes reverse design calls the spec had recorded, and the spec now records the new ones:

  • On Fastly, a turned-off /auction no longer records the browser's EID cookies.
  • Proxy callers that do not stream no longer run the creative pass while rewrite_creatives = false.

5e5df5b1f also fixes the shim's remaining adUnitCodes differences from Prebid, which the earlier follow-up list named. 0f7792ecf drops that commit's handling of a single ad unit object, because real Prebid 10.26 rejects one too (TypeError: n.map is not a function). GTM's proxy path and first-party-proxy.md, the other two items, are fixed in 3ce2d715b, so no follow-up is left.

Calls for the reviewer to check

These are design calls the spec makes that nobody has confirmed yet:

  1. /first-party/click and /first-party/proxy-rebuild follow click wrapping (rewrites_auction_clicks()), not rewrite_creatives alone.
  2. This reverses Make creative click rewriting a separate feature with its own switch #1234's "routed and ungated" click endpoints. After a switch-off, clicks on creatives already on a page get a 404.
  3. /_ts/page-bids and /__ts/page-bids do not change.
  4. A turned-off /auction no longer emits the auction_disabled telemetry event or the skipped server-side trace. Publisher page loads and /_ts/page-bids still record both.
  5. The turned-off 404 carries Cache-Control: no-store, private and the terminal-private marker. Fastly then restores the policy after late request-filter header changes.
  6. On Fastly, a turned-off /auction records none of the browser's cookie EIDs, unlike today's disabled branch. Review round 1 decided this, and it is the one adapter dispatch change.
  7. With the auction off, the shim also drops a trustedServer bid the publisher configured.
  8. A Prebid config without auctionEnabled means the auction is on.
  9. Fastly request filters keep precedence. On a DataDome-protected service, a turned-off /auction still gets the verdict call, and a challenge answers before the 404.
  10. "Reads no body" starts at the handler. EdgeZero ingress still buffers bodies before routing, and changing that would mean changing EdgeZero.
  11. The shim's ad-unit selection now matches Prebid's requestBids, with the auction on as well as off.

Process

  • Skills:
    • superpowers:brainstorming: spec, approval gate and a cold builder read of the spec;
    • superpowers:writing-plans: plan and self-review;
    • superpowers:subagent-driven-development: implementation, with a review after each task and a whole-branch review at the end.
  • Account mode: one account. CREATOR and REVIEWER both act as the PR author's account, and comments start with CREATOR: or REVIEWER: .

Validation

All local runs were at 0f7792ecf on macOS (arm64), with Viceroy 0.22.0, and every command exited 0. The same suite also passed at 3ce2d715b, the review-fix commit, and at 5e5df5b1f.

Gate Result
cargo fmt --all -- --check, also for the integration-tests crate clean
cargo build-fastly, build-axum, build-cloudflare and the Fastly release build built
The eight Clippy aliases, plus the integration-tests crate no warnings
cargo test-fastly 3,708 passed, 0 failed
cargo test-fastly-reuse 248 passed, 0 failed
cargo test-axum 62 passed, 0 failed
cargo test-cloudflare 59 passed, 0 failed
cargo test-spin 98 passed, 0 failed
Parity 31 passed, 0 failed
JS npx vitest run Tests 3315 passed (3315)
Prebid artifact test shim characters: 52549
JS lint and format clean
Docs format, lint and build; Markdown Prettier clean; build complete
template_build_digest test and Clippy 10 passed, 0 failed; no warnings
scripts/lint-wasm-clock.sh clean
Docs-proposal scripts shellcheck clean; pass 20; script tests passed
ts dev lint domains --changed-vs origin/main no findings
CI Node pin guard pass 30; 34 jobs in 10 workflows pin Node before compiling Rust
Fastly deadline-origin fixtures 5 passed, 0 failed
Worker deadline fixtures: build and Clippy, Cloudflare and Spin built; no warnings
Cloudflare deadline runtime (wasm-bindgen 0.2.126, wrangler 4.83.0) 4 of 4 passed
Spin deadline runtime 5 of 5 passed
Release producer checks pass 27; shellcheck clean
scripts/test-cli.sh 965 passed, 0 failed
Codegen tests 7 passed, 0 failed
template-cache-local-test.sh (esi, inline, purge) 22 passed, 0 failed; 9 passed, 0 failed; 34 passed, 0 failed

The Cloudflare deadline runtime used the Cargo.lock wasm-bindgen CLI (0.2.126) and CI's wrangler@4.83.0, installed in a scratch directory.

The HTML EOF checks were not run locally, because this PR changes no publisher, HTML-processor or EOF code. CI runs them.

CI results for 0f7792ecf are reported by GitHub; earlier runs are not counted for this head.

The Prebid shim adds a trustedServer bid to every ad unit whatever [auction].enabled says, so it would keep sending POST /auction and log a bidder failure on every 404. The design now has the server flag the auction state in the injected Prebid config and the shim drop its bid when the auction is off. It also records that Fastly can still sync cookie EIDs on a turned-off /auction and adds TESTING.md and the Prebid guide to the docs to update.
Plans the shared turned-off 404 helper, the five handler gates, the adapter and parity route tests, the injected auctionEnabled flag that stops the Prebid shim calling /auction, and the docs and changelog updates for #1669.
@aram356
aram356 marked this pull request as draft November 27, 2026 20:18
The spec now matches the plan: the two trace tests move to the consent-denied branch, which keeps their policy_skipped assertions, and the Prebid test it names is the kill-switch test. The changelog entry covers the Prebid shim. The plan adds the auction deadline fixtures to the final gate run, gives Fastly its own turned-off settings, names the parity request helpers, and records which browser fixtures run with the switches off.
Narrow the no-body-read guarantee to the handler, since EdgeZero ingress buffers bodies before routing. Keep Fastly request filters ahead of the switch and document it. Mark the turned-off 404 terminal-private so late Fastly filter headers cannot make it cacheable, with a send-boundary test. Treat adUnitCodes: [] as every global ad unit, as Prebid does, and run the refresh regression through the shim. Restore every AGENTS.md gate in the final run, add the deadline fixture Clippy runs, and add the auction orchestration and DataDome guides to the docs work.
Removing trustedServer bids misses a publisher alias of the adapter, because Prebid copies the adapter spec for an alias and snapshot-backed refresh keeps the alias as browser demand. The plan now has buildRequests return no requests while the injected flag is off, with alias and refresh tests. It also keeps the handler qualifier in the TESTING.md wording, limits the DataDome note about cached pages to Prebid callers, and describes which browser specs rely on endpoints that stay on.
@aram356 aram356 changed the title Spec and plan for turning off creative and auction endpoints by switch Turn off creative and auction endpoints when their switch is off Nov 28, 2026

@aram356 aram356 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

REVIEWER: REQUEST_CHANGES

GitHub blocked this review event: the REQUEST_CHANGES submission returned HTTP 422 "Review Can not request changes on your own pull request", because the acting login is the PR author. This COMMENT review carries the same verdict and findings. It is not an approval.

  • Reviewed head: 468873720, against base db36dc0ec (main). Phase: implementation.
  • Account mode: one account. The acting login is the PR author's.
  • Planning gate: the spec and plan were not approved in a separate planning PR, because the user asked for spec, plan and implementation in this one PR. I reviewed the implementation against the spec at this head.
  • Scope: the diff changes runtime Rust, TypeScript, tests, docs and the example config. It is not documentation-only, so I ran the full prescribed suite.

Findings

There are four should-fix findings and six nits, each in its own thread.

Should-fix:

  1. On Fastly, a turned-off POST /auction still authorizes EID persistence (auction/endpoints.rs:139).
  2. The non-streaming proxy path still writes URLs for endpoints that are turned off (creative.rs:1177).
  3. The adapter and parity tests lost their default-config coverage (adapter-axum/tests/routes.rs:41).
  4. docs/guide/first-party-proxy.md still describes the endpoints as always on (anchored at api-reference.md:74).

Nits:

  • the walkthrough is missing the auction-on precondition;
  • the click debug line names a key that may be unset;
  • the Fastly test message overclaims, and no route test checks Content-Type;
  • the DataDome note isn't scoped to Fastly;
  • the example TOML comment sits in the wrong place;
  • the shim-size comment is stale.

Validation

Every check ran at 468873720, in my detached worktree .worktrees/review-1675-4688737, with this setup:

  • macOS arm64, rustc 1.98.1, Node 24.20.0, viceroy 0.22.0, spin 4.1.0.
  • The disk had 13 GiB free, so the cargo target dir is shared with the author's worktree. The fresh checkout rebuilt every workspace crate; the logs show Compiling trusted-server-core v0.1.0 (.../review-1675-4688737/crates/trusted-server-core).

Each command exited 0.

Command Result
cargo fmt --all -- --check; cargo fmt --manifest-path crates/trusted-server-integration-tests/Cargo.toml -- --check no output
cargo clippy-fastly, clippy-axum, clippy-cloudflare, clippy-cloudflare-wasm, clippy-spin-native, clippy-spin-wasm, clippy-cli, clippy-codegen; cargo clippy --manifest-path crates/trusted-server-integration-tests/Cargo.toml --all-targets -- -D warnings no clippy warnings. The only warning: lines are the proc-macro-error2 v2.0.1 future-incompat note and the tsjs build info.
cargo test-fastly 7 test result: ok. lines: 3705 passed, 0 failed, 31 ignored
cargo test-fastly-reuse test result: ok. 246 passed; 0 failed; 5 ignored
cargo test-axum / test-cloudflare / test-spin 61 / 58 / 97 passed, 0 failed
cargo test --manifest-path crates/trusted-server-integration-tests/Cargo.toml --test parity test result: ok. 30 passed; 0 failed
npx vitest run (in crates/trusted-server-js/lib) Test Files 80 passed (80), Tests 3312 passed | 1 skipped (3313)
npx vitest run test/prebid-artifact-integration.test.mjs --reporter=verbose --silent=false Tests 13 passed (13); shim characters: 52602
npm run lint and npm run format (JS); npm run format, npm run lint and npm run build (docs) All matched files use Prettier code style!; build complete
docs/node_modules/.bin/prettier --config docs/.prettierrc --check "*.md" ".claude/**/*.md" ".github/**/*.md" "crates/**/*.md" "scripts/**/*.md" "tinybird/**/*.md" All matched files use Prettier code style!
cargo test -p trusted-server-core --test template_build_digest; its cargo clippy ... -- -D warnings 10 passed, 0 failed; no warnings
scripts/lint-wasm-clock.sh exit 0
shellcheck scripts/docs-proposal/*.sh; node --test scripts/docs-proposal/hunks.test.mjs; scripts/docs-proposal/test.sh pass 20, fail 0; All documentation proposal script tests passed.
cargo run --manifest-path crates/trusted-server-cli/Cargo.toml --target aarch64-apple-darwin --bin ts -- dev lint domains --changed-vs origin/main no findings
node --test scripts/check-ci-node-pin.test.mjs; node scripts/check-ci-node-pin.mjs pass 30, fail 0; ok: 34 jobs in 10 workflows pin Node before compiling Rust
node crates/trusted-server-adapter-fastly/tests/deadline-origin.mjs "$(command -v viceroy)" test result: ok. 5 passed; 0 failed
Cloudflare and Spin deadline-runtime example builds and their cargo clippy ... -- -D warnings built; no warnings
node scripts/test-worker-auction-deadlines.mjs spin --runtime "$(command -v spin)" 5 PASS spin ... lines
node scripts/test-worker-auction-deadlines.mjs cloudflare --runtime <wrangler 4.83.0> 4 PASS cloudflare ... lines
node --test scripts/release/phase1.test.mjs; shellcheck scripts/release/phase1-build.sh pass 27, fail 0
./scripts/test-cli.sh; cargo test --package trusted-server-openrtb-codegen --target aarch64-apple-darwin 965 passed, 0 failed; 7 passed
BID_DELAY=3 ./scripts/template-cache-local-test.sh with esi, inline and purge 22 passed, 0 failed, 9 passed, 0 failed, 34 passed, 0 failed

Setup problems on my side:

  • The first Spin and Cloudflare deadline-runtime runs exited 1 with failed to read component source from disk at path .../target/.... The script reads the repository's target/ directory, and my run created that link only after those runs. Both passed on rerun.
  • The Cloudflare run also needs the Cargo.lock wasm-bindgen CLI (0.2.126) and CI's wrangler@4.83.0. I installed both into a scratch directory; this machine has 0.2.121 and 4.131.0.

Not run locally:

  • The HTML EOF checks: this PR changes no publisher, HTML-processor or EOF code.
  • The Docker integration and browser jobs.

GitHub CI reports all 30 checks passing at 468873720, including those. That is CI's result, not a run of mine.

services: &RuntimeServices,
req: Request<EdgeBody>,
) -> Result<Response<EdgeBody>, Report<TrustedServerError>> {
if !orchestrator.is_enabled() {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

REVIEWER: should-fix On Fastly, a turned-off POST /auction still authorizes EID persistence, because the adapter sets it up before this gate runs.

Evidence, read at 468873720:

  • crates/trusted-server-adapter-fastly/src/app.rs:676 calls ec.ec_context.set_eid_sync_source(EidSyncSource::Auction);, and :677 builds PartnerRegistry::from_config(...)?. Both run before handle_auction reaches this check.
  • With that source set, ec/finalize.rs:79-111 collects the ts-eids and sharedId cookie EIDs for a returning, consented EC and calls sync_eid_cookie_updates, which writes them to KV.
  • The adapter's own filter_short_circuit_response_is_not_eligible_for_eid_persistence (app.rs:3679-3713) states the rule for requests that serve nothing: "No publisher page or auction was served, so the challenged request must not write EIDs". It asserts eid_sync_source_of(&auction) == None. A turned-off /auction serves no auction either.
  • The new text says the endpoint "calls no provider and emits no telemetry event" (docs/guide/api-reference.md:201-202, and TESTING.md:128-129 likewise). An operator reads that as the request doing nothing.

The spec keeps this as a call "open to review". As reviewer, I'd stop it: the switch is meant to turn the endpoint off.

Hypothesis, not run: the KV snapshot this loads also lets run_edgezero_pull_sync_after_send (main.rs:554, via build_pull_sync_context in ec/pull_sync.rs:86-91) send partner pull-sync requests after a turned-off answer.

  • Check: in a Fastly app.rs test, take test_settings(), set auction.enabled = false, route browser_request(Method::POST, "/auction", "empty"), and assert eid_sync_source_of(&response) == None.
  • Some(EidSyncSource::Auction) confirms the tag, and so the write path. None withdraws this finding.

Correction:

  • In the Fastly Auction arm, set the sync source and build the registry only while state.orchestrator.is_enabled(). Or return the turned-off answer before both.
  • Add the test above.
  • If you keep the behaviour instead, say so in api-reference.md and TESTING.md, and name the possible pull sync in the spec.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

CREATOR: fixed in 3ce2d715b.

  • crates/trusted-server-adapter-fastly/src/app.rs: the Auction arm now sets EidSyncSource::Auction and builds PartnerRegistry::from_config only while state.orchestrator.is_enabled(). A turned-off /auction reaches handle_auction with no sync source and no registry, and gets the turned-off 404.
  • New test turned_off_auction_is_not_eligible_for_eid_persistence, the check you named: test_settings() with auction.enabled = false, browser_request(Method::POST, "/auction", "empty"), then 404 and eid_sync_source_of(&auction) == None.
  • The spec's call at line 90 now records the decision. api-reference.md, TESTING.md and CHANGELOG.md say a turned-off /auction records none of the browser's EID cookies on Fastly.

Verification

  • Before the fix, at 468873720 plus the new test: cargo test -p trusted-server-adapter-fastly --target wasm32-wasip1 --bin trusted-server-adapter-fastly turned_off_auction_is_not_eligible_for_eid_persistence exited 134. The wasm backtrace ends in assert_failed::<Option<EidSyncSource>> at app.rs:2941, the eid_sync_source_of(&auction) == None assertion, after the status assertion passed. That confirms the finding.
  • After the fix, the same command with dispatch_limits_returning_user_eid_sync_to_eligible_routes and filter_short_circuit_response_is_not_eligible_for_eid_persistence exited 0: test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 249 filtered out. The first still sees Some(EidSyncSource::Auction) with the auction on.
  • At head 5e5df5b1f: cargo test-fastly exited 0: 7 test result: ok. lines, 3708 passed, 0 failed, with turned_off_auction_is_not_eligible_for_eid_persistence ... ok. cargo test-fastly-reuse exited 0: 1 test result: ok. line, 248 passed, 0 failed.

Pull sync, not tested. By reading only: with no sync source, the returning-user branch in ec/finalize.rs no longer calls sync_eid_cookie_updates, which is where this request loaded the KV snapshot that build_pull_sync_context (ec/pull_sync.rs:86) reads. I did not check every other place that could load it, and the route tests have no KV graph, so I make no pull-sync claim.

Comment on lines +1177 to +1179
/// turned-off `404`. Other proxy callers that do not stream, such as the
/// Google Tag Manager integration, still run it on HTML responses whatever
/// `rewrite_creatives` says. Asset rewriting is unconditional, and click

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

REVIEWER: should-fix This documents that non-streaming proxy callers still run the creative pass while rewrite_creatives = false. In that state, the pass writes URLs for the very endpoints this PR turns off, which the spec says cannot happen.

Evidence, read at 468873720:

  • proxy.rs:676-695 (finalize_proxied_response) runs CreativeHtmlProcessor on any text/html response and CreativeCssProcessor on any text/css one. Neither has a rewrite_creatives check.
  • integrations/google_tag_manager.rs:917 builds ProxyRequestConfig::new(target_url) without .with_streaming(), so GTM responses take that path.
  • With rewrite_creatives = false, the pass writes /first-party/proxy?tsurl= asset URLs, and those now answer 404.
  • With rewrite_clicks unset, rewrites_proxied_clicks() is true (auction_config_types.rs:197-199) while the click gate's rewrites_auction_clicks() is false. Links are wrapped to /first-party/click, and the click then gets the 404.
    • The spec's switch table says it avoids exactly this wrap-then-404 case.
    • It also contradicts the spec's "No other feature emits them" and "Proxied HTML only exists while /first-party/proxy is on".
  • auction_rewrite_setting_does_not_change_proxied_html_or_css_rewriting (proxy.rs:4186-4227) asserts this output. The plan said to delete it; ead56f57b kept it. Its name, its GET /first-party/proxy request and its messages describe a state that route can no longer reach.

The reach is narrow, by reading only: GTM answers with JavaScript, a GIF or a 204 on success. So only an upstream text/html or text/css answer, such as an error page, takes this pass.

Correction (preferred):

  • Skip both creative processors in finalize_proxied_response while !settings.auction.rewrite_creatives.
    • /first-party/proxy already needs that switch, so its behaviour doesn't change.
    • Any click wrapping that is left then always agrees with the click gate.
  • Turn the kept test into one that asserts no /first-party/ URL appears.
  • Update this comment, the module doc (lines 44-49), the CreativeHtmlProcessor doc (lines 1592-1601) and docs/guide/configuration.md:2409-2411.

If you keep the behaviour instead:

  • correct the spec's premise;
  • rename the kept test after the GTM caller;
  • file the follow-up issue the PR body lists, and link it here.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

CREATOR: fixed in 3ce2d715b, with the preferred correction.

  • proxy.rs finalize_proxied_response skips both CreativeHtmlProcessor and CreativeCssProcessor while !settings.auction.rewrite_creatives. In that state the HEAD branch keeps the upstream Content-Length, because a GET no longer rewrites the body.
  • Callers on this path, from a grep of proxy_request and stream_passthrough: /first-party/proxy, which already needs the switch, and the GTM integration (google_tag_manager.rs:917). testlight sets stream_passthrough = true, and handle_asset_proxy_request never reaches the creative processors.
  • The kept test is now creative_rewriting_off_passes_proxied_html_and_css_through_unchanged. With rewrite_creatives = false and each rewrite_clicks of None, Some(true) and Some(false), GET HTML and CSS come back byte-identical with Content-Type and Content-Length kept, and HEAD keeps Content-Length. Its request path is /integrations/example/asset, not /first-party/proxy.
  • proxied_html_click_wrapping_follows_explicit_rewrite_clicks, on main before this PR, had three rewrite_creatives = false rows that asserted wrapping. Those rows are gone; it now covers rewrite_clicks while the pass runs.
  • Docs: this comment, the module doc, the CreativeHtmlProcessor doc, configuration.md (the rewrite_clicks overlay note: the leaf keeps today's behavior when it equals rewrite_creatives), creative-processing.md, the Buffered note in first-party-proxy.md, spec lines 13 and 61 plus a new acceptance criterion, and CHANGELOG.md.

Verification

  • Before the fix the new test failed: cargo test -p trusted-server-core --target aarch64-apple-darwin --lib -- proxy::tests::creative_rewriting_off_passes_proxied_html_and_css_through_unchanged exited 101 with assertion \left == right` failed: GET text/html; charset=utf-8 with rewrite_clicks=None: should keep the upstream Content-Length`.
  • After the fix: cargo test -p trusted-server-core --target aarch64-apple-darwin --lib -- proxy::tests:: exited 0, test result: ok. 155 passed; 0 failed.
  • At head 5e5df5b1f: cargo test-fastly exited 0: 7 test result: ok. lines, 3708 passed, 0 failed, with creative_rewriting_off_passes_proxied_html_and_css_through_unchanged ... ok and proxied_html_click_wrapping_follows_explicit_rewrite_clicks ... ok.

Comment on lines +41 to +42
[auction]
enabled = true

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

REVIEWER: should-fix Turning the auction on in the shared route settings leaves no adapter-level test of the default config. The new turned-off tests also can't tell which switch produced each 404.

Evidence from the diff:

  • This adds [auction] enabled = true to the shared settings here. The PR does the same in crates/trusted-server-adapter-cloudflare/tests/routes.rs:49, crates/trusted-server-adapter-spin/tests/routes.rs:48 and crates/trusted-server-integration-tests/tests/parity.rs:60.
    • So the existing first_party_*_is_routed tests and proxy_rebuild_get_route_parity now all run with the auction on.
    • Before this PR they ran under the default, auction off.
  • Every turned-off setup sets enabled = false and rewrite_creatives = false together: turned_off_settings() here (:889-894) and in parity.rs:67-72, turned_off_router() in Cloudflare (:698-705) and Spin (:746-753), and the Fastly turned_off_endpoints_answer_404_locally (app.rs:2877-2880). An adapter that gated /first-party/* on auction.enabled, or /auction on rewrite_creatives, would pass all of them.
  • Only the core test creative_endpoints_follow_their_switches covers the spec's anti-goal "a default configuration loses a creative endpoint" and its criterion "the creative endpoints follow only their own switches", and it calls the handlers directly.

Correction: pick one.

  • Keep the shared settings at the default, and give only the /auction routed tests an auction-on copy.
  • Or add two cases per adapter and in parity:
    • auction off with the default creative switches: each creative endpoint's body is not ENDPOINT_TURNED_OFF_BODY, and POST /auction is turned off;
    • auction on with rewrite_creatives = false: POST /auction is not turned off.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

CREATOR: fixed in 3ce2d715b, with the second option, in all four adapters and in parity.

  • New each_switch_turns_off_only_its_own_endpoints in Fastly app.rs and in the Axum, Cloudflare and Spin tests/routes.rs, plus each_switch_turns_off_only_its_own_endpoints_parity in parity.rs.
  • Each sends TURNED_OFF_REQUESTS under two settings: enabled = false with the default creative switches, which is the default auction config, and enabled = true with rewrite_creatives = false. /auction must answer the turned-off 404 exactly when the auction is off, and each creative request exactly when rewrite_creatives is off.
  • "Turned off" means 404 with ENDPOINT_TURNED_OFF_BODY, so the "still on" side is decided by the body, never by the status alone.
  • The shared settings keep enabled = true, so the existing routed /auction tests keep exercising a running auction.

Mutation evidence. Each mutation ran against all five new tests, then the file was restored and the working diff hash checked identical to before:

  • handle_first_party_proxy gated on !settings.auction.enabled: Axum, Cloudflare, Spin and parity exited 101 with GET /first-party/proxy with auction.enabled = false, rewrite_creatives = true: should follow only its own switch. Fastly exited 134 at that assertion (app.rs:2969).
  • handle_auction gated on !settings.auction.rewrite_creatives: the same five failed with POST /auction with auction.enabled = false, rewrite_creatives = true: should follow only its own switch, Fastly with 134 at app.rs:2969.

At head 5e5df5b1f

  • cargo test-fastly exited 0: 7 test result: ok. lines, 3708 passed, 0 failed, with each_switch_turns_off_only_its_own_endpoints ... ok.
  • cargo test-axum exited 0: 4 test result: ok. lines, 62 passed, 0 failed; cargo test-cloudflare exited 0: 4 test result: ok. lines, 59 passed, 0 failed; cargo test-spin exited 0: 3 test result: ok. lines, 98 passed, 0 failed. Each ran each_switch_turns_off_only_its_own_endpoints ... ok.
  • cargo test --manifest-path crates/trusted-server-integration-tests/Cargo.toml --test parity exited 0: 1 test result: ok. line, 31 passed, 0 failed, with each_switch_turns_off_only_its_own_endpoints_parity ... ok.

Comment on lines +74 to +82
For `/auction` and the four `/first-party/` creative routes, the predicate
names the switch that turns the endpoint on. The route stays registered while
its switch is off. Its listed methods then return `404` with the plain-text
body `This endpoint is turned off` and `Cache-Control: no-store, private`, and
the request never reaches the publisher fallback. Other methods on these paths
still go to the publisher fallback. On Fastly, an integration request filter
such as DataDome runs before routing, so its answer keeps precedence over this
`404`.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

REVIEWER: should-fix docs/guide/first-party-proxy.md is the guide dedicated to these four endpoints. This PR doesn't update it, and it still describes them as always on. I've anchored the finding here, on the text that guide should link to, because the PR doesn't touch the file.

Evidence: at 468873720, grep -n "rewrite_creatives\|turned off\|404" docs/guide/first-party-proxy.md prints nothing. Its Core Endpoints, Configuration and Common Errors sections name no switch and no turned-off 404.

Correction:

  • Add an availability line for each endpoint, or one note under Core Endpoints, giving its switch and the turned-off 404.
    • Link this section and Auction Configuration.
    • Repeat the warning that creatives already on a page break once a switch is turned off.
  • Add a 404 This endpoint is turned off entry to Common Errors.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

CREATOR: fixed in 3ce2d715b. docs/guide/first-party-proxy.md now has:

  • under Core Endpoints, a table of each endpoint's switch, the turned-off 404 with its body and Cache-Control, links to Route availability and Auction Configuration, and a warning that creatives already on a page stop loading proxied assets or redirecting clicks once a switch is off;
  • a new Endpoint Turned Off entry in Common Errors;
  • a Buffered note that HTML and CSS rewriting needs rewrite_creatives = true.

Verification at head 5e5df5b1f: cd docs && npm run format exited 0 (All matched files use Prettier code style!); cd docs && npm run lint exited 0; cd docs && npm run build exited 0 (build complete in 6.68s.).

Check the response and logs for these invariants:

- a disabled auction returns a no-bid response without provider dispatch;
- a disabled auction returns the turned-off `404` without provider dispatch;

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

REVIEWER: nit The walkthrough above this list never says to turn the auction on.

  • [auction].enabled defaults to false.
  • With this PR, the curl --fail-with-body ... /auction at lines 34-38 then exits non-zero on the turned-off 404. Before the PR it got a 200 no-bid answer.
  • This PR adds exactly that precondition to docs/guide/error-reference.md:699-700.

Correction: start line 30 with "Set [auction].enabled = true, configure each provider endpoint ...".

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

CREATOR: fixed in 3ce2d715b. Line 30 now starts "Set [auction].enabled = true, configure each provider endpoint to a controlled fixture, then send a Prebid-compatible request:".

Verification at head 5e5df5b1f: cd docs && npm run format exited 0 (All matched files use Prettier code style!); cd docs && npm run build exited 0 (build complete in 6.68s.).

Comment thread crates/trusted-server-core/src/proxy.rs Outdated
if !settings.auction.rewrites_auction_clicks() {
return Ok(endpoint_turned_off_response(
"/first-party/click",
"auction.rewrite_clicks",

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

REVIEWER: nit This can name a key the operator never set.

  • With rewrite_clicks unset and rewrite_creatives = false, the debug line reads "answering /first-party/click locally with 404 because auction.rewrite_clicks is off".
  • The gate is rewrites_auction_clicks(), which is rewrite_clicks.unwrap_or(rewrite_creatives) (auction_config_types.rs:187-189).
  • The endpoint_turned_off_response doc says the line names "the setting that turns it on".
  • /first-party/proxy-rebuild has the same problem at line 1944.

Correction: pass "auction.rewrite_clicks" only when rewrite_clicks.is_some(), and "auction.rewrite_creatives" otherwise.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

CREATOR: fixed in 3ce2d715b.

  • A new private auction_clicks_switch(settings) in proxy.rs returns "auction.rewrite_clicks" when rewrite_clicks.is_some(), and "auction.rewrite_creatives" otherwise. Both the /first-party/click and the /first-party/proxy-rebuild gates pass it to endpoint_turned_off_response.
  • New test auction_clicks_switch_names_the_setting_that_decides_click_wrapping covers None, Some(false) and Some(true).

Verification at head 5e5df5b1f: cargo test-fastly exited 0: 7 test result: ok. lines, 3708 passed, 0 failed, with auction_clicks_switch_names_the_setting_that_decides_click_wrapping ... ok.

.extensions()
.get::<TerminalPrivateResponse>()
.is_some(),
"{label}: should reach the send boundary marked terminal-private"

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

REVIEWER: nit Two small gaps in the turned-off route tests.

  • This message overclaims. It says the response reaches the send boundary, but the test only calls route(&router, ...). edgezero_main's finalization and send_edgezero_response never run.
  • No turned-off loop checks Content-Type. None of the loops (this one, Axum, Cloudflare, Spin and turned_off_endpoints_parity) checks Content-Type: text/plain; charset=utf-8. The plan's Global Constraints list it together with the status, the body and Cache-Control, and only the core assert_endpoint_turned_off checks it.

Correction:

  • Reword this message to "should leave the router marked terminal-private".
  • Add the Content-Type check to each of those loops.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

CREATOR: fixed in 3ce2d715b.

  • The message now reads "should leave the router marked terminal-private".
  • Every turned-off loop now checks Content-Type: text/plain; charset=utf-8: Fastly turned_off_endpoints_answer_404_locally, the Axum, Cloudflare and Spin turned_off_endpoints_answer_404_locally, and turned_off_endpoints_parity.

Verification at head 5e5df5b1f

  • cargo test-fastly exited 0: 7 test result: ok. lines, 3708 passed, 0 failed, with turned_off_endpoints_answer_404_locally ... ok.
  • cargo test-axum exited 0: 4 test result: ok. lines, 62 passed, 0 failed; cargo test-cloudflare exited 0: 4 test result: ok. lines, 59 passed, 0 failed; cargo test-spin exited 0: 3 test result: ok. lines, 98 passed, 0 failed.
  • cargo test --manifest-path crates/trusted-server-integration-tests/Cargo.toml --test parity exited 0: 1 test result: ok. line, 31 passed, 0 failed, with turned_off_endpoints_parity ... ok.

Comment thread docs/guide/integrations/datadome.md Outdated
Comment on lines +175 to +178
Auction traffic at `/auction` is protected by default. While
`[auction].enabled = false`, a protected `/auction` request still goes through
protection first. A challenge or block answers before the turned-off `404`, and
each such request can still cost one Protection API call.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

REVIEWER: nit This paragraph isn't scoped to Fastly.

  • Among the adapters, only crates/trusted-server-adapter-fastly/src/app.rs uses IntegrationRequestFilter (rg -l IntegrationRequestFilter crates).
  • The new text at docs/guide/api-reference.md:79-81 says "On Fastly".
  • "each such request" also reads as challenged requests only. In fact any protected /auction request, allowed or not, can cost the verdict call.

Correction: "On Fastly, while [auction].enabled = false, a protected /auction request still goes through protection first. A challenge or block answers before the turned-off 404, and every protected request, allowed or not, can still cost one Protection API call."

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

CREATOR: fixed in 3ce2d715b, with your wording: "On Fastly, while [auction].enabled = false, a protected /auction request still goes through protection first. A challenge or block answers before the turned-off 404, and every protected request, allowed or not, can still cost one Protection API call."

Verification at head 5e5df5b1f: cd docs && npm run format exited 0 (All matched files use Prettier code style!); cd docs && npm run build exited 0 (build complete in 6.68s.).

# Keep disabled until provider endpoints, routes, and profile values below are
# replaced with deployment-specific settings.
enabled = false
# While disabled, POST /auction is turned off and answers a 404.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

REVIEWER: nit This line sits directly above the rewrite_creatives comment block with nothing between them, so it reads as that block's first line.

Correction: add a blank line after it. That fixes it without touching the [auction] ... enabled = false text that scripts/template-cache-local-test.sh:304-311 replaces.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

CREATOR: fixed in 3ce2d715b. A blank line now follows "# While disabled, POST /auction is turned off and answers a 404.", so it no longer reads as the first line of the rewrite_creatives block. The [auction] ... enabled = false text that scripts/template-cache-local-test.sh replaces is unchanged.

Verification at head 5e5df5b1f: BID_DELAY=3 ./scripts/template-cache-local-test.sh exited 0 for esi (22 passed, 0 failed), inline (9 passed, 0 failed) and purge (34 passed, 0 failed).

Comment on lines +379 to +383
// 11,676 characters (52,030 total). Keep a narrow guard: Prebid remains a separate artifact above 200 KB, and importing
// its runtime or private rendering helpers must still fail this regression.
expect(shimCode.length).toBeLessThan(52_500);
// Skipping the trustedServer bid and request while the auction is off adds
// about 140 characters, so the guard is 52.75 KB.
expect(shimCode.length).toBeLessThan(52_750);

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

REVIEWER: nit The comment's numbers don't support the new guard.

  • By its own figures the shim is 52,030 characters. Adding about 140 gives 52,170, which is still under the old 52,500, yet the guard moved.
  • My npx vitest run test/prebid-artifact-integration.test.mjs --reporter=verbose --silent=false at 468873720 printed [trace-prebid-artifact] shim characters: 52602. That is 148 under the new guard, so the 52,030 figure is stale.

Correction: replace the stale total with the measured size, and say how much headroom the 52,750 guard leaves.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

CREATOR: fixed in 3ce2d715b, with the size updated again in 5e5df5b1f.

  • The comment now gives the measured size instead of the stale 52,030 total, and says how much headroom the 52.75 KB guard leaves.
  • 5e5df5b1f also makes the shim select ad units as Prebid does, which shrank it from 52,602 to 52,574 characters, so the comment now says 52,574 characters and 176 characters of headroom.

Verification at head 5e5df5b1f: npx vitest run test/prebid-artifact-integration.test.mjs --reporter=verbose --silent=false exited 0 and printed [trace-prebid-artifact] shim characters: 52574 and Tests 13 passed (13).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

CREATOR: fixed follow-up at 0f7792ecf. That commit drops the shim's handling of a single ad unit object, because real Prebid 10.26 rejects one too (TypeError: n.map is not a function), and the shim shrinks to 52,549 characters. The comment now says 52,549 characters and 201 of headroom under the 52.75 KB guard.

Verification at head 0f7792ecf: npx vitest run test/prebid-artifact-integration.test.mjs --reporter=verbose --silent=false exited 0 and printed [trace-prebid-artifact] shim characters: 52549 and Tests 13 passed (13).

- Set Fastly's /auction EID sync source and build its partner registry
  only while the auction is on, so a turned-off request writes no EIDs.
- Pass HTML and CSS from proxy callers that do not stream through
  unchanged while rewrite_creatives is off, instead of writing URLs for
  turned-off endpoints, and keep Content-Length on HEAD in that state.
- Add per-adapter and parity tests that each switch turns off only its
  own endpoints, and check Content-Type on every turned-off answer.
- Name the setting that actually decides click wrapping in the click
  gates' turned-off log line.
- Document the switches in the first-party proxy guide, record both
  review decisions in the spec, and fix the remaining doc nits.
The shim chose its ad units differently from Prebid 10.26's
requestBids and filterAdUnits: a single adUnitCodes string selected
every global unit, adUnitCodes did not narrow explicit adUnits, and a
single ad unit object passed as adUnits made the shim throw before
Prebid ran. Accept one unit or a list, fall back to pbjs.adUnits, and
narrow by one code or a list unless adUnitCodes is absent or empty.
Prebid 10.26's requestBids rejects a single ad unit object passed as
adUnits (TypeError: n.map is not a function), so wrapping one in the
shim only added the shim's side effects before Prebid threw. Take
explicit adUnits as given, as Prebid does, and drop the claim from the
docs and the CHANGELOG.

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.

Turn off first-party creative endpoints and POST /auction when their switch is off

1 participant