-
Notifications
You must be signed in to change notification settings - Fork 12
Preserve integration configuration string types #933
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
e55d985
5eef5f1
02c985f
cbef72f
0d6c22a
e62ff90
973e279
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -289,11 +289,6 @@ pub struct PrebidIntegrationConfig { | |
| /// param1 = 12345 | ||
| /// param2 = "value" | ||
| /// ``` | ||
| /// | ||
| /// Example via environment variable: | ||
| /// ```text | ||
| /// TRUSTED_SERVER__INTEGRATIONS__PREBID__BID_PARAM_OVERRIDES='{"bidder-name":{"param1":12345,"param2":"value"}}' | ||
| /// ``` | ||
| #[serde(default)] | ||
| pub bid_param_overrides: HashMap<String, serde_json::Map<String, Json>>, | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📌 out of scope — Removing these |
||
| /// Canonical ordered bidder-param override rules. | ||
|
|
@@ -311,11 +306,6 @@ pub struct PrebidIntegrationConfig { | |
| /// when.zone = "header" | ||
| /// set = { placementId = "_abc" } | ||
| /// ``` | ||
| /// | ||
| /// Example via environment variable: | ||
| /// ```text | ||
| /// TRUSTED_SERVER__INTEGRATIONS__PREBID__BID_PARAM_OVERRIDE_RULES='[{"when":{"bidder":"kargo","zone":"header"},"set":{"placementId":"_abc"}}]' | ||
| /// ``` | ||
| #[serde(default)] | ||
| pub bid_param_override_rules: Vec<BidParamOverrideRule>, | ||
| /// How consent signals are forwarded to Prebid Server. | ||
|
|
@@ -5728,6 +5718,91 @@ set = { keywords = { genre = "news" } } | |
| ) | ||
| } | ||
|
|
||
| #[test] | ||
| fn bid_param_override_numeric_strings_survive_runtime_config_roundtrip() { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 praise — This is the right shape for the regression test. Going through |
||
| let toml_str = format!( | ||
| r#"{} | ||
|
|
||
| [integrations.prebid] | ||
| enabled = true | ||
| server_url = "https://prebid.example" | ||
| bidders = ["pubmatic"] | ||
|
|
||
| [integrations.prebid.bid_param_overrides.pubmatic] | ||
| publisherId = "12345" | ||
| adSlot = "67890" | ||
|
|
||
| [integrations.prebid.bid_param_zone_overrides.pubmatic] | ||
| header = {{ placementId = "24680" }} | ||
|
|
||
| [[integrations.prebid.bid_param_override_rules]] | ||
| when = {{ bidder = "pubmatic", zone = "in_content" }} | ||
| set = {{ placementId = "13579" }} | ||
| "#, | ||
| TOML_BASE | ||
| ); | ||
| let settings = Settings::from_toml(&toml_str).expect("should parse TOML settings"); | ||
|
|
||
| // This mirrors the typed data transition beneath `ts config push`: | ||
| // `BlobEnvelope` data is deserialized by `settings_from_config_blob`. | ||
| let serialized = serde_json::to_value(&settings).expect("should serialize settings"); | ||
| let runtime_settings = | ||
| Settings::from_json_value(serialized).expect("should parse runtime JSON settings"); | ||
| let config = runtime_settings | ||
| .integration_config::<PrebidIntegrationConfig>(PREBID_INTEGRATION_ID) | ||
| .expect("should parse Prebid config") | ||
| .expect("should enable Prebid config"); | ||
|
|
||
| let static_request = make_auction_request(vec![make_ts_slot( | ||
| "ad-static-0", | ||
| &json!({ "pubmatic": { "keep": "client" } }), | ||
| None, | ||
| )]); | ||
| let static_ortb = call_to_openrtb(config.clone(), &static_request); | ||
| let static_params = bidder_params(&static_ortb); | ||
| assert_eq!( | ||
| static_params["pubmatic"]["publisherId"], | ||
| json!("12345"), | ||
| "static override publisherId should remain a string" | ||
| ); | ||
| assert_eq!( | ||
| static_params["pubmatic"]["adSlot"], | ||
| json!("67890"), | ||
| "static override adSlot should remain a string" | ||
| ); | ||
| assert_eq!( | ||
| static_params["pubmatic"]["keep"], | ||
| json!("client"), | ||
| "static override should preserve client parameters" | ||
| ); | ||
|
|
||
| let header_request = make_auction_request(vec![make_ts_slot( | ||
| "ad-header-0", | ||
| &json!({ "pubmatic": {} }), | ||
| Some("header"), | ||
| )]); | ||
| let header_ortb = call_to_openrtb(config.clone(), &header_request); | ||
| let header_params = bidder_params(&header_ortb); | ||
| assert_eq!( | ||
| header_params["pubmatic"]["placementId"], | ||
| json!("24680"), | ||
| "zone override placementId should remain a string" | ||
| ); | ||
|
|
||
| let in_content_request = make_auction_request(vec![make_ts_slot( | ||
| "ad-in-content-0", | ||
| &json!({ "pubmatic": {} }), | ||
| Some("in_content"), | ||
| )]); | ||
| let in_content_ortb = call_to_openrtb(config, &in_content_request); | ||
| let in_content_params = bidder_params(&in_content_ortb); | ||
| assert_eq!( | ||
| in_content_params["pubmatic"]["placementId"], | ||
| json!("13579"), | ||
| "canonical rule placementId should remain a string" | ||
| ); | ||
| } | ||
|
|
||
| #[test] | ||
| fn zone_override_replaces_placement_id() { | ||
| let mut config = base_config(); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝 note — Accurate for typed fields, but the sentence "quoted numeric and boolean scalars now fail validation" could be misread as applying to the free-form bidder-param maps too. Those are the opposite:
bid_param_overrides/bid_param_zone_overrides/ rulesetvalues areserde_json::Map<String, Json>, sopublisherId = "12345"is now preserved as a string rather than failing — which is the whole fix. Consider a trailing clause, e.g. "… free-form bidder-param override values are preserved verbatim (a quoted"12345"stays a string)." Non-blocking.