Skip to content

Implement generic Prebid bid param override rules#618

Open
prk-Jr wants to merge 15 commits intomainfrom
feature/generic-prebid-bidder-param-overrides
Open

Implement generic Prebid bid param override rules#618
prk-Jr wants to merge 15 commits intomainfrom
feature/generic-prebid-bidder-param-overrides

Conversation

@prk-Jr
Copy link
Copy Markdown
Collaborator

@prk-Jr prk-Jr commented Apr 6, 2026

Summary

  • Replaces the split Prebid bidder-param override runtime with one generic ordered override engine.
  • Keeps bid_param_overrides and bid_param_zone_overrides as compatibility config, while adding canonical bid_param_override_rules for future config-driven overrides.
  • Normalizes all override config into one validated rule list at startup and applies rules by exact bidder / zone match with shallow last-write-wins merges.

Changes

File Change
crates/trusted-server-core/src/integrations/prebid.rs Add BidParamOverrideRule, BidParamOverrideWhen, and BidParamOverrideEngine; normalize compatibility fields and canonical rules into one runtime path; apply rules during OpenRTB construction; update tests
crates/trusted-server-core/src/settings.rs Add env var override test for TRUSTED_SERVER__INTEGRATIONS__PREBID__BID_PARAM_OVERRIDE_RULES
trusted-server.toml Document canonical bid_param_override_rules and clarify that compatibility fields normalize into the same engine
docs/superpowers/plans/2026-04-08-prebid-generic-bid-param-override-rules.md Add implementation plan used for this branch

Closes

Closes #617

Related: #339, #383, #384

Test plan

  • cargo fmt --all -- --check
  • cargo test -p trusted-server-core
  • cargo clippy -p trusted-server-core --all-targets --all-features -- -D warnings
  • cargo test --workspace
  • cargo clippy --workspace --all-targets --all-features -- -D warnings

Checklist

  • Changes follow CLAUDE.md conventions
  • Uses log macros (not println!)
  • New code has tests
  • No secrets or credentials committed

@prk-Jr prk-Jr self-assigned this Apr 6, 2026
Renames the new field to match the existing `bid_param_zone_overrides`
naming convention. Updates all references: struct field, env var key,
doc comments, TOML example, tests, and .env.example.

Also replaces production IDs in test fixtures and examples with
generic placeholder values.
@prk-Jr prk-Jr marked this pull request as draft April 8, 2026 09:34
@prk-Jr prk-Jr changed the title Add generic per-bidder static param overrides for PBS Implement generic Prebid bid param override rules Apr 8, 2026
Copy link
Copy Markdown
Collaborator

@ChristianPavilonis ChristianPavilonis left a comment

Choose a reason for hiding this comment

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

Well-designed feature. The BidParamOverrideEngine with its canonical rule format and compatibility normalization from bid_param_overrides/bid_param_zone_overrides is a clean architecture. Good validation at startup via try_from_config and json_object_for_override. Test coverage is thorough — especially the engine unit tests and precedence ordering tests. A few suggestions below.

@prk-Jr prk-Jr marked this pull request as ready for review April 8, 2026 15:38
Copy link
Copy Markdown
Collaborator

@ChristianPavilonis ChristianPavilonis left a comment

Choose a reason for hiding this comment

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

Well-designed PR — the unified rule engine is clean, well-tested, and the compatibility migration strategy is sound. Approving with two recommended fixes.

Copy link
Copy Markdown
Collaborator

@aram356 aram356 left a comment

Choose a reason for hiding this comment

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

Summary

Replaces the split bid-param override paths with a single generic BidParamOverrideEngine that normalizes all three config surfaces into an ordered rule list at startup. Clean design, solid compatibility story, comprehensive tests.

Non-blocking

♻️ refactor

  • Redundant validation-only engine build in PrebidIntegration::try_new: builds and discards the engine just for validation — same work is repeated in PrebidAuctionProvider::try_new (prebid.rs:233)

🤔 thinking

  • deny_unknown_fields on BidParamOverrideWhen: strict is good, but adding new matcher fields later becomes a breaking config change (prebid.rs:189)
  • Shallow merge semantics vs. nested override values: real-world bidder params can be nested objects — shallow merge replaces the entire value rather than deep-merging (prebid.rs:504)

⛏ nitpick

  • parse_prebid_toml_result error message: "should be enabled" is misleading when None could also mean the section is missing entirely (prebid.rs:1627)

🌱 seedling

  • Zone-only rules (no bidder): the engine requires at least one matcher, so "for all bidders in zone X" rules aren't possible yet — could be useful for zone-wide floor overrides

CI Status

  • fmt: PASS
  • clippy: PASS
  • cargo test: PASS
  • vitest: PASS
  • integration tests: PASS
  • browser integration tests: PASS

@prk-Jr prk-Jr requested a review from aram356 April 10, 2026 11:12
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.

Add generic per-bidder static param overrides for PBS

3 participants