From f645156db09633c87d7b41080e7113dc7fcabb70 Mon Sep 17 00:00:00 2001 From: Scott Kay Date: Thu, 18 Mar 2021 19:58:42 -0400 Subject: [PATCH 1/3] FPD imp.ext.data Passthrough To Adapters --- ...=> valid-fpd-allowed-with-ext-bidder.json} | 33 +++++++++---------- ...valid-fpd-allowed-with-prebid-bidder.json} | 31 +++++++++-------- exchange/utils.go | 4 +++ exchange/utils_test.go | 11 +++++++ openrtb_ext/request.go | 5 ++- 5 files changed, 50 insertions(+), 34 deletions(-) rename endpoints/openrtb2/sample-requests/first-party-data/{valid-context-allowed-with-ext-bidder.json => valid-fpd-allowed-with-ext-bidder.json} (64%) rename endpoints/openrtb2/sample-requests/first-party-data/{valid-context-allowed-with-prebid-bidder.json => valid-fpd-allowed-with-prebid-bidder.json} (72%) diff --git a/endpoints/openrtb2/sample-requests/first-party-data/valid-context-allowed-with-ext-bidder.json b/endpoints/openrtb2/sample-requests/first-party-data/valid-fpd-allowed-with-ext-bidder.json similarity index 64% rename from endpoints/openrtb2/sample-requests/first-party-data/valid-context-allowed-with-ext-bidder.json rename to endpoints/openrtb2/sample-requests/first-party-data/valid-fpd-allowed-with-ext-bidder.json index 74dede0857f..c36ae0cd41d 100644 --- a/endpoints/openrtb2/sample-requests/first-party-data/valid-context-allowed-with-ext-bidder.json +++ b/endpoints/openrtb2/sample-requests/first-party-data/valid-fpd-allowed-with-ext-bidder.json @@ -21,30 +21,29 @@ "appnexus": { "placementId": 12883451 }, + "data": { + "keywords": "prebid server example" + }, "context": { "data": { - "keywords": "prebid server example" + "keywords": "another prebid server example" } } } }] }, "expectedBidResponse": { - "id":"some-request-id", - "seatbid": [ - { - "bid": [ - { - "id": "appnexus-bid", - "impid": "", - "price": 0 - } - ], - "seat": "appnexus-bids" - } - ], - "bidid":"test bid id", - "nbr":0 + "id": "some-request-id", + "seatbid": [{ + "bid": [{ + "id": "appnexus-bid", + "impid": "", + "price": 0 + }], + "seat": "appnexus-bids" + }], + "bidid": "test bid id", + "nbr": 0 }, "expectedReturnCode": 200 -} +} \ No newline at end of file diff --git a/endpoints/openrtb2/sample-requests/first-party-data/valid-context-allowed-with-prebid-bidder.json b/endpoints/openrtb2/sample-requests/first-party-data/valid-fpd-allowed-with-prebid-bidder.json similarity index 72% rename from endpoints/openrtb2/sample-requests/first-party-data/valid-context-allowed-with-prebid-bidder.json rename to endpoints/openrtb2/sample-requests/first-party-data/valid-fpd-allowed-with-prebid-bidder.json index 41461813c40..7fb533e82ae 100644 --- a/endpoints/openrtb2/sample-requests/first-party-data/valid-context-allowed-with-prebid-bidder.json +++ b/endpoints/openrtb2/sample-requests/first-party-data/valid-fpd-allowed-with-prebid-bidder.json @@ -25,6 +25,9 @@ } } }, + "data": { + "keywords": "prebid server example" + }, "context": { "data": { "keywords": "prebid server example" @@ -34,21 +37,17 @@ }] }, "expectedBidResponse": { - "id":"some-request-id", - "seatbid": [ - { - "bid": [ - { - "id": "appnexus-bid", - "impid": "", - "price": 0 - } - ], - "seat": "appnexus-bids" - } - ], - "bidid":"test bid id", - "nbr":0 + "id": "some-request-id", + "seatbid": [{ + "bid": [{ + "id": "appnexus-bid", + "impid": "", + "price": 0 + }], + "seat": "appnexus-bids" + }], + "bidid": "test bid id", + "nbr": 0 }, "expectedReturnCode": 200 -} +} \ No newline at end of file diff --git a/exchange/utils.go b/exchange/utils.go index 4ca02149453..d127bc9889d 100644 --- a/exchange/utils.go +++ b/exchange/utils.go @@ -384,6 +384,10 @@ func createSanitizedImpExt(impExt, impExtPrebid map[string]json.RawMessage) (map } } + if v, exists := impExt[openrtb_ext.FirstPartyDataExtKey]; exists { + sanitizedImpExt[openrtb_ext.FirstPartyDataExtKey] = v + } + if v, exists := impExt[openrtb_ext.FirstPartyDataContextExtKey]; exists { sanitizedImpExt[openrtb_ext.FirstPartyDataContextExtKey] = v } diff --git a/exchange/utils_test.go b/exchange/utils_test.go index 1945aee1b98..f8603f18f4f 100644 --- a/exchange/utils_test.go +++ b/exchange/utils_test.go @@ -233,6 +233,7 @@ func TestCreateSanitizedImpExt(t *testing.T) { description: "imp.ext.prebid - Bidders Only", givenImpExt: map[string]json.RawMessage{ "prebid": json.RawMessage(`"ignoredInFavorOfSeparatelyUnmarshalledImpExtPrebid"`), + "data": json.RawMessage(`"anyData"`), "context": json.RawMessage(`"anyContext"`), "skadn": json.RawMessage(`"anySKAdNetwork"`), }, @@ -240,6 +241,7 @@ func TestCreateSanitizedImpExt(t *testing.T) { "bidder": json.RawMessage(`"anyBidder"`), }, expected: map[string]json.RawMessage{ + "data": json.RawMessage(`"anyData"`), "context": json.RawMessage(`"anyContext"`), "skadn": json.RawMessage(`"anySKAdNetwork"`), }, @@ -249,6 +251,7 @@ func TestCreateSanitizedImpExt(t *testing.T) { description: "imp.ext.prebid - Bidders + Other Values", givenImpExt: map[string]json.RawMessage{ "prebid": json.RawMessage(`"ignoredInFavorOfSeparatelyUnmarshalledImpExtPrebid"`), + "data": json.RawMessage(`"anyData"`), "context": json.RawMessage(`"anyContext"`), "skadn": json.RawMessage(`"anySKAdNetwork"`), }, @@ -258,6 +261,7 @@ func TestCreateSanitizedImpExt(t *testing.T) { }, expected: map[string]json.RawMessage{ "prebid": json.RawMessage(`{"someOther":"value"}`), + "data": json.RawMessage(`"anyData"`), "context": json.RawMessage(`"anyContext"`), "skadn": json.RawMessage(`"anySKAdNetwork"`), }, @@ -267,11 +271,13 @@ func TestCreateSanitizedImpExt(t *testing.T) { description: "imp.ext", givenImpExt: map[string]json.RawMessage{ "anyBidder": json.RawMessage(`"anyBidderValues"`), + "data": json.RawMessage(`"anyData"`), "context": json.RawMessage(`"anyContext"`), "skadn": json.RawMessage(`"anySKAdNetwork"`), }, givenImpExtPrebid: map[string]json.RawMessage{}, expected: map[string]json.RawMessage{ + "data": json.RawMessage(`"anyData"`), "context": json.RawMessage(`"anyContext"`), "skadn": json.RawMessage(`"anySKAdNetwork"`), }, @@ -282,6 +288,7 @@ func TestCreateSanitizedImpExt(t *testing.T) { givenImpExt: map[string]json.RawMessage{ "anyBidder": json.RawMessage(`"anyBidderValues"`), "prebid": json.RawMessage(`"ignoredInFavorOfSeparatelyUnmarshalledImpExtPrebid"`), + "data": json.RawMessage(`"anyData"`), "context": json.RawMessage(`"anyContext"`), "skadn": json.RawMessage(`"anySKAdNetwork"`), }, @@ -289,6 +296,7 @@ func TestCreateSanitizedImpExt(t *testing.T) { "bidder": json.RawMessage(`"anyBidder"`), }, expected: map[string]json.RawMessage{ + "data": json.RawMessage(`"anyData"`), "context": json.RawMessage(`"anyContext"`), "skadn": json.RawMessage(`"anySKAdNetwork"`), }, @@ -299,6 +307,7 @@ func TestCreateSanitizedImpExt(t *testing.T) { givenImpExt: map[string]json.RawMessage{ "anyBidder": json.RawMessage(`"anyBidderValues"`), "prebid": json.RawMessage(`"ignoredInFavorOfSeparatelyUnmarshalledImpExtPrebid"`), + "data": json.RawMessage(`"anyData"`), "context": json.RawMessage(`"anyContext"`), "skadn": json.RawMessage(`"anySKAdNetwork"`), }, @@ -308,6 +317,7 @@ func TestCreateSanitizedImpExt(t *testing.T) { }, expected: map[string]json.RawMessage{ "prebid": json.RawMessage(`{"someOther":"value"}`), + "data": json.RawMessage(`"anyData"`), "context": json.RawMessage(`"anyContext"`), "skadn": json.RawMessage(`"anySKAdNetwork"`), }, @@ -317,6 +327,7 @@ func TestCreateSanitizedImpExt(t *testing.T) { description: "Marshal Error - imp.ext.prebid", givenImpExt: map[string]json.RawMessage{ "prebid": json.RawMessage(`"ignoredInFavorOfSeparatelyUnmarshalledImpExtPrebid"`), + "data": json.RawMessage(`"anyData"`), "context": json.RawMessage(`"anyContext"`), "skadn": json.RawMessage(`"anySKAdNetwork"`), }, diff --git a/openrtb_ext/request.go b/openrtb_ext/request.go index b2bb25e7401..f673c737eab 100644 --- a/openrtb_ext/request.go +++ b/openrtb_ext/request.go @@ -5,7 +5,10 @@ import ( "errors" ) -// FirstPartyDataContextExtKey defines the field name within request.ext reserved for first party data. +// FirstPartyDataExtKey defines a field name within request.ext and request.imp.ext reserved for first party data. +const FirstPartyDataExtKey = "data" + +// FirstPartyDataContextExtKey defines a field name within request.ext and request.imp.ext reserved for first party data. const FirstPartyDataContextExtKey = "context" // SKAdNExtKey defines the field name within request.ext reserved for Apple's SKAdNetwork. From 2d036f2b04a502c376c128bf2e459b9119cab5df Mon Sep 17 00:00:00 2001 From: Scott Kay Date: Fri, 19 Mar 2021 13:13:53 -0400 Subject: [PATCH 2/3] Add Bidder Validation Exception --- endpoints/openrtb2/auction.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/endpoints/openrtb2/auction.go b/endpoints/openrtb2/auction.go index d26623da348..70d8e72629e 100644 --- a/endpoints/openrtb2/auction.go +++ b/endpoints/openrtb2/auction.go @@ -898,6 +898,8 @@ func isBidderToValidate(bidder string) bool { switch openrtb_ext.BidderName(bidder) { case openrtb_ext.BidderReservedContext: return false + case openrtb_ext.BidderReservedData: + return false case openrtb_ext.BidderReservedPrebid: return false case openrtb_ext.BidderReservedSKAdN: From 8c8d0c88041a552e4265438b5426ae0f03b4b7f4 Mon Sep 17 00:00:00 2001 From: Scott Kay Date: Fri, 19 Mar 2021 13:37:58 -0400 Subject: [PATCH 3/3] Expanded Tests + Fix Missed Check --- .../valid-fpd-allowed-with-prebid-bidder.json | 2 +- .../firstpartydata-imp-ext-multiple-bidders.json | 15 ++++++++++++--- ...artydata-imp-ext-multiple-prebid-bidders.json | 15 ++++++++++++--- .../firstpartydata-imp-ext-one-bidder.json | 10 ++++++++-- .../firstpartydata-imp-ext-one-prebid-bidder.json | 10 ++++++++-- exchange/utils.go | 1 + 6 files changed, 42 insertions(+), 11 deletions(-) diff --git a/endpoints/openrtb2/sample-requests/first-party-data/valid-fpd-allowed-with-prebid-bidder.json b/endpoints/openrtb2/sample-requests/first-party-data/valid-fpd-allowed-with-prebid-bidder.json index 7fb533e82ae..ad6298db39a 100644 --- a/endpoints/openrtb2/sample-requests/first-party-data/valid-fpd-allowed-with-prebid-bidder.json +++ b/endpoints/openrtb2/sample-requests/first-party-data/valid-fpd-allowed-with-prebid-bidder.json @@ -30,7 +30,7 @@ }, "context": { "data": { - "keywords": "prebid server example" + "keywords": "another prebid server example" } } } diff --git a/exchange/exchangetest/firstpartydata-imp-ext-multiple-bidders.json b/exchange/exchangetest/firstpartydata-imp-ext-multiple-bidders.json index 8004c3c2646..df0e4e33ea5 100644 --- a/exchange/exchangetest/firstpartydata-imp-ext-multiple-bidders.json +++ b/exchange/exchangetest/firstpartydata-imp-ext-multiple-bidders.json @@ -25,9 +25,12 @@ "siteId": 2, "zoneId": 3 }, + "data": { + "keywords": "prebid server example" + }, "context": { "data": { - "keywords": "prebid server example" + "keywords": "another prebid server example" } } } @@ -57,9 +60,12 @@ "bidder": { "placementId": 1 }, + "data": { + "keywords": "prebid server example" + }, "context": { "data": { - "keywords": "prebid server example" + "keywords": "another prebid server example" } } } @@ -107,9 +113,12 @@ "siteId": 2, "zoneId": 3 }, + "data": { + "keywords": "prebid server example" + }, "context": { "data": { - "keywords": "prebid server example" + "keywords": "another prebid server example" } } } diff --git a/exchange/exchangetest/firstpartydata-imp-ext-multiple-prebid-bidders.json b/exchange/exchangetest/firstpartydata-imp-ext-multiple-prebid-bidders.json index 37654c454bc..ea4a980c63f 100644 --- a/exchange/exchangetest/firstpartydata-imp-ext-multiple-prebid-bidders.json +++ b/exchange/exchangetest/firstpartydata-imp-ext-multiple-prebid-bidders.json @@ -29,9 +29,12 @@ } } }, + "data": { + "keywords": "prebid server example" + }, "context": { "data": { - "keywords": "prebid server example" + "keywords": "another prebid server example" } } } @@ -61,9 +64,12 @@ "bidder": { "placementId": 1 }, + "data": { + "keywords": "prebid server example" + }, "context": { "data": { - "keywords": "prebid server example" + "keywords": "another prebid server example" } } } @@ -111,9 +117,12 @@ "siteId": 2, "zoneId": 3 }, + "data": { + "keywords": "prebid server example" + }, "context": { "data": { - "keywords": "prebid server example" + "keywords": "another prebid server example" } } } diff --git a/exchange/exchangetest/firstpartydata-imp-ext-one-bidder.json b/exchange/exchangetest/firstpartydata-imp-ext-one-bidder.json index 6f0bab9529c..7e2c4b9a16d 100644 --- a/exchange/exchangetest/firstpartydata-imp-ext-one-bidder.json +++ b/exchange/exchangetest/firstpartydata-imp-ext-one-bidder.json @@ -20,9 +20,12 @@ "appnexus": { "placementId": 1 }, + "data": { + "keywords": "prebid server example" + }, "context": { "data": { - "keywords": "prebid server example" + "keywords": "another prebid server example" } } } @@ -52,9 +55,12 @@ "bidder": { "placementId": 1 }, + "data": { + "keywords": "prebid server example" + }, "context": { "data": { - "keywords": "prebid server example" + "keywords": "another prebid server example" } } } diff --git a/exchange/exchangetest/firstpartydata-imp-ext-one-prebid-bidder.json b/exchange/exchangetest/firstpartydata-imp-ext-one-prebid-bidder.json index c931b0b9ee3..f1977426591 100644 --- a/exchange/exchangetest/firstpartydata-imp-ext-one-prebid-bidder.json +++ b/exchange/exchangetest/firstpartydata-imp-ext-one-prebid-bidder.json @@ -24,9 +24,12 @@ } } }, + "data": { + "keywords": "prebid server example" + }, "context": { "data": { - "keywords": "prebid server example" + "keywords": "another prebid server example" } } } @@ -56,9 +59,12 @@ "bidder": { "placementId": 1 }, + "data": { + "keywords": "prebid server example" + }, "context": { "data": { - "keywords": "prebid server example" + "keywords": "another prebid server example" } } } diff --git a/exchange/utils.go b/exchange/utils.go index d127bc9889d..0d9d0e3ced8 100644 --- a/exchange/utils.go +++ b/exchange/utils.go @@ -423,6 +423,7 @@ func extractBidderExts(impExt, impExtPrebidBidders map[string]json.RawMessage) m func isSpecialField(bidder string) bool { return bidder == openrtb_ext.FirstPartyDataContextExtKey || + bidder == openrtb_ext.FirstPartyDataExtKey || bidder == openrtb_ext.SKAdNExtKey || bidder == openrtb_ext.PrebidExtKey }