From 6201719d7fba6b0097d599a82e9343136311c252 Mon Sep 17 00:00:00 2001 From: Piotr Jaworski Date: Thu, 9 Oct 2025 11:01:18 +0200 Subject: [PATCH 1/3] RTBHouse: PMP removal, publisherId extraction --- adapters/rtbhouse/rtbhouse.go | 39 +++- .../exemplary/ae-igs-removal.json | 114 ++++++++++++ .../exemplary/app-with-publisher.json | 116 ++++++++++++ .../bidfloor-as-bidder-param-without-cur.json | 5 + .../exemplary/bidfloor-as-bidder-param.json | 5 + .../bidfloor-as-impbidfloor-with-cur.json | 5 + .../bidfloor-as-impbidfloor-without-cur.json | 5 + .../existing-site-publisher-override.json | 117 ++++++++++++ .../multiple-imps-different-publishers.json | 167 ++++++++++++++++++ .../exemplary/pmp-removal-test.json | 117 ++++++++++++ ...bidfloors-given-param-and-impbidfloor.json | 5 + .../supplemental/malformed-imp-ext.json | 25 +++ 12 files changed, 716 insertions(+), 4 deletions(-) create mode 100644 adapters/rtbhouse/rtbhousetest/exemplary/ae-igs-removal.json create mode 100644 adapters/rtbhouse/rtbhousetest/exemplary/app-with-publisher.json create mode 100644 adapters/rtbhouse/rtbhousetest/exemplary/existing-site-publisher-override.json create mode 100644 adapters/rtbhouse/rtbhousetest/exemplary/multiple-imps-different-publishers.json create mode 100644 adapters/rtbhouse/rtbhousetest/exemplary/pmp-removal-test.json create mode 100644 adapters/rtbhouse/rtbhousetest/supplemental/malformed-imp-ext.json diff --git a/adapters/rtbhouse/rtbhouse.go b/adapters/rtbhouse/rtbhouse.go index 9a7e3f4f924..c0e472da4fc 100644 --- a/adapters/rtbhouse/rtbhouse.go +++ b/adapters/rtbhouse/rtbhouse.go @@ -45,14 +45,23 @@ func (adapter *RTBHouseAdapter) MakeRequests( reqCopy := *openRTBRequest reqCopy.Imp = []openrtb2.Imp{} + + var publisherId string + for _, imp := range openRTBRequest.Imp { + rtbhouseExt, err := getImpressionExt(imp) + if err != nil { + return nil, []error{err} + } + + // Extract publisherId from the first impression that has one + if publisherId == "" && rtbhouseExt.PublisherId != "" { + publisherId = rtbhouseExt.PublisherId + } + var bidFloorCur = imp.BidFloorCur var bidFloor = imp.BidFloor if bidFloorCur == "" && bidFloor == 0 { - rtbhouseExt, err := getImpressionExt(imp) - if err != nil { - return nil, []error{err} - } if rtbhouseExt.BidFloor > 0 { bidFloor = rtbhouseExt.BidFloor bidFloorCur = BidderCurrency @@ -90,11 +99,33 @@ func (adapter *RTBHouseAdapter) MakeRequests( } imp.Ext = newImpExt + // Remove PMP from impression + imp.PMP = nil + // Set the CUR of bid to BIDDER_CURRENCY after converting all floors reqCopy.Cur = []string{BidderCurrency} reqCopy.Imp = append(reqCopy.Imp, imp) } + // Set publisher ID in site.publisher.id if we found one + if publisherId != "" { + if reqCopy.Site == nil { + reqCopy.Site = &openrtb2.Site{} + } else { + // Create a copy of the site to avoid modifying the original request + siteCopy := *reqCopy.Site + reqCopy.Site = &siteCopy + } + if reqCopy.Site.Publisher == nil { + reqCopy.Site.Publisher = &openrtb2.Publisher{} + } else { + // Create a copy of the publisher to avoid modifying the original request + publisherCopy := *reqCopy.Site.Publisher + reqCopy.Site.Publisher = &publisherCopy + } + reqCopy.Site.Publisher.ID = publisherId + } + openRTBRequestJSON, err := json.Marshal(reqCopy) if err != nil { errs = append(errs, err) diff --git a/adapters/rtbhouse/rtbhousetest/exemplary/ae-igs-removal.json b/adapters/rtbhouse/rtbhousetest/exemplary/ae-igs-removal.json new file mode 100644 index 00000000000..31422c65efa --- /dev/null +++ b/adapters/rtbhouse/rtbhousetest/exemplary/ae-igs-removal.json @@ -0,0 +1,114 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ] + }, + "ext": { + "ae": 1, + "igs": { + "biddable": 1 + }, + "bidder": { + "publisherId": "12345" + }, + "someOtherField": "should-remain" + } + } + ] + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://localhost/prebid_server", + "body": { + "id": "test-request-id", + "cur": [ + "USD" + ], + "imp": [ + { + "banner": { + "format": [ + { + "h": 250, + "w": 300 + } + ] + }, + "ext": { + "bidder": { + "publisherId": "12345" + }, + "someOtherField": "should-remain" + }, + "id": "test-imp-id" + } + ], + "site": { + "publisher": { + "id": "12345" + } + } + }, + "impIDs": ["test-imp-id"] + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-response-id", + "cur": "USD", + "seatbid": [ + { + "seat": "rtbhouse", + "bid": [ + { + "id": "randomid", + "impid": "test-imp-id", + "price": 300, + "adid": "12345678", + "adm": "some-test-ad", + "cid": "987", + "crid": "12345678", + "h": 250, + "w": 300, + "mtype": 1 + } + ] + } + ] + } + } + } + ], + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "id": "randomid", + "impid": "test-imp-id", + "price": 300, + "adid": "12345678", + "adm": "some-test-ad", + "cid": "987", + "crid": "12345678", + "h": 250, + "w": 300, + "mtype": 1 + }, + "type": "banner" + } + ] + } + ] +} \ No newline at end of file diff --git a/adapters/rtbhouse/rtbhousetest/exemplary/app-with-publisher.json b/adapters/rtbhouse/rtbhousetest/exemplary/app-with-publisher.json new file mode 100644 index 00000000000..5cbeca115c2 --- /dev/null +++ b/adapters/rtbhouse/rtbhousetest/exemplary/app-with-publisher.json @@ -0,0 +1,116 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "app": { + "bundle": "com.example.app", + "name": "Test App" + }, + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ] + }, + "ext": { + "bidder": { + "publisherId": "app-publisher-123" + } + } + } + ] + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://localhost/prebid_server", + "body": { + "id": "test-request-id", + "cur": [ + "USD" + ], + "app": { + "bundle": "com.example.app", + "name": "Test App" + }, + "imp": [ + { + "banner": { + "format": [ + { + "h": 250, + "w": 300 + } + ] + }, + "ext": { + "bidder": { + "publisherId": "app-publisher-123" + } + }, + "id": "test-imp-id" + } + ], + "site": { + "publisher": { + "id": "app-publisher-123" + } + } + }, + "impIDs": ["test-imp-id"] + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-response-id", + "cur": "USD", + "seatbid": [ + { + "seat": "rtbhouse", + "bid": [ + { + "id": "randomid", + "impid": "test-imp-id", + "price": 300, + "adid": "12345678", + "adm": "some-test-ad", + "cid": "987", + "crid": "12345678", + "h": 250, + "w": 300, + "mtype": 1 + } + ] + } + ] + } + } + } + ], + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "id": "randomid", + "impid": "test-imp-id", + "price": 300, + "adid": "12345678", + "adm": "some-test-ad", + "cid": "987", + "crid": "12345678", + "h": 250, + "w": 300, + "mtype": 1 + }, + "type": "banner" + } + ] + } + ] +} \ No newline at end of file diff --git a/adapters/rtbhouse/rtbhousetest/exemplary/bidfloor-as-bidder-param-without-cur.json b/adapters/rtbhouse/rtbhousetest/exemplary/bidfloor-as-bidder-param-without-cur.json index 9b0f8d3e38b..f8db7dec760 100644 --- a/adapters/rtbhouse/rtbhousetest/exemplary/bidfloor-as-bidder-param-without-cur.json +++ b/adapters/rtbhouse/rtbhousetest/exemplary/bidfloor-as-bidder-param-without-cur.json @@ -63,6 +63,11 @@ "id": "test-imp-id" } ], + "site": { + "publisher": { + "id": "12345" + } + }, "ext": { "prebid": { "currency": { diff --git a/adapters/rtbhouse/rtbhousetest/exemplary/bidfloor-as-bidder-param.json b/adapters/rtbhouse/rtbhousetest/exemplary/bidfloor-as-bidder-param.json index c6a82faa574..4da3eaa132c 100644 --- a/adapters/rtbhouse/rtbhousetest/exemplary/bidfloor-as-bidder-param.json +++ b/adapters/rtbhouse/rtbhousetest/exemplary/bidfloor-as-bidder-param.json @@ -66,6 +66,11 @@ "id": "test-imp-id" } ], + "site": { + "publisher": { + "id": "12345" + } + }, "ext": { "prebid": { "currency": { diff --git a/adapters/rtbhouse/rtbhousetest/exemplary/bidfloor-as-impbidfloor-with-cur.json b/adapters/rtbhouse/rtbhousetest/exemplary/bidfloor-as-impbidfloor-with-cur.json index b0b34a25afe..7520c3b6c92 100644 --- a/adapters/rtbhouse/rtbhousetest/exemplary/bidfloor-as-impbidfloor-with-cur.json +++ b/adapters/rtbhouse/rtbhousetest/exemplary/bidfloor-as-impbidfloor-with-cur.json @@ -63,6 +63,11 @@ "id": "test-imp-id" } ], + "site": { + "publisher": { + "id": "12345" + } + }, "ext": { "prebid": { "currency": { diff --git a/adapters/rtbhouse/rtbhousetest/exemplary/bidfloor-as-impbidfloor-without-cur.json b/adapters/rtbhouse/rtbhousetest/exemplary/bidfloor-as-impbidfloor-without-cur.json index a6dbcec864a..680daecd5ba 100644 --- a/adapters/rtbhouse/rtbhousetest/exemplary/bidfloor-as-impbidfloor-without-cur.json +++ b/adapters/rtbhouse/rtbhousetest/exemplary/bidfloor-as-impbidfloor-without-cur.json @@ -61,6 +61,11 @@ "id": "test-imp-id" } ], + "site": { + "publisher": { + "id": "12345" + } + }, "ext": { "prebid": { "currency": { diff --git a/adapters/rtbhouse/rtbhousetest/exemplary/existing-site-publisher-override.json b/adapters/rtbhouse/rtbhousetest/exemplary/existing-site-publisher-override.json new file mode 100644 index 00000000000..db990523a56 --- /dev/null +++ b/adapters/rtbhouse/rtbhousetest/exemplary/existing-site-publisher-override.json @@ -0,0 +1,117 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "site": { + "page": "https://example.com", + "publisher": { + "id": "existing-publisher", + "name": "Existing Publisher" + } + }, + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ] + }, + "ext": { + "bidder": { + "publisherId": "new-publisher-123" + } + } + } + ] + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://localhost/prebid_server", + "body": { + "id": "test-request-id", + "cur": [ + "USD" + ], + "site": { + "page": "https://example.com", + "publisher": { + "id": "new-publisher-123", + "name": "Existing Publisher" + } + }, + "imp": [ + { + "banner": { + "format": [ + { + "h": 250, + "w": 300 + } + ] + }, + "ext": { + "bidder": { + "publisherId": "new-publisher-123" + } + }, + "id": "test-imp-id" + } + ] + }, + "impIDs": ["test-imp-id"] + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-response-id", + "cur": "USD", + "seatbid": [ + { + "seat": "rtbhouse", + "bid": [ + { + "id": "randomid", + "impid": "test-imp-id", + "price": 300, + "adid": "12345678", + "adm": "some-test-ad", + "cid": "987", + "crid": "12345678", + "h": 250, + "w": 300, + "mtype": 1 + } + ] + } + ] + } + } + } + ], + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "id": "randomid", + "impid": "test-imp-id", + "price": 300, + "adid": "12345678", + "adm": "some-test-ad", + "cid": "987", + "crid": "12345678", + "h": 250, + "w": 300, + "mtype": 1 + }, + "type": "banner" + } + ] + } + ] +} \ No newline at end of file diff --git a/adapters/rtbhouse/rtbhousetest/exemplary/multiple-imps-different-publishers.json b/adapters/rtbhouse/rtbhousetest/exemplary/multiple-imps-different-publishers.json new file mode 100644 index 00000000000..4ce3baa26d9 --- /dev/null +++ b/adapters/rtbhouse/rtbhousetest/exemplary/multiple-imps-different-publishers.json @@ -0,0 +1,167 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id-1", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ] + }, + "ext": { + "bidder": { + "publisherId": "first-publisher" + } + } + }, + { + "id": "test-imp-id-2", + "banner": { + "format": [ + { + "w": 728, + "h": 90 + } + ] + }, + "ext": { + "bidder": { + "publisherId": "second-publisher" + } + } + } + ] + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://localhost/prebid_server", + "body": { + "id": "test-request-id", + "cur": [ + "USD" + ], + "imp": [ + { + "banner": { + "format": [ + { + "h": 250, + "w": 300 + } + ] + }, + "ext": { + "bidder": { + "publisherId": "first-publisher" + } + }, + "id": "test-imp-id-1" + }, + { + "banner": { + "format": [ + { + "h": 90, + "w": 728 + } + ] + }, + "ext": { + "bidder": { + "publisherId": "second-publisher" + } + }, + "id": "test-imp-id-2" + } + ], + "site": { + "publisher": { + "id": "first-publisher" + } + } + }, + "impIDs": ["test-imp-id-1", "test-imp-id-2"] + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-response-id", + "cur": "USD", + "seatbid": [ + { + "seat": "rtbhouse", + "bid": [ + { + "id": "randomid1", + "impid": "test-imp-id-1", + "price": 300, + "adid": "12345678", + "adm": "some-test-ad-1", + "cid": "987", + "crid": "12345678", + "h": 250, + "w": 300, + "mtype": 1 + }, + { + "id": "randomid2", + "impid": "test-imp-id-2", + "price": 150, + "adid": "87654321", + "adm": "some-test-ad-2", + "cid": "789", + "crid": "87654321", + "h": 90, + "w": 728, + "mtype": 1 + } + ] + } + ] + } + } + } + ], + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "id": "randomid1", + "impid": "test-imp-id-1", + "price": 300, + "adid": "12345678", + "adm": "some-test-ad-1", + "cid": "987", + "crid": "12345678", + "h": 250, + "w": 300, + "mtype": 1 + }, + "type": "banner" + }, + { + "bid": { + "id": "randomid2", + "impid": "test-imp-id-2", + "price": 150, + "adid": "87654321", + "adm": "some-test-ad-2", + "cid": "789", + "crid": "87654321", + "h": 90, + "w": 728, + "mtype": 1 + }, + "type": "banner" + } + ] + } + ] +} \ No newline at end of file diff --git a/adapters/rtbhouse/rtbhousetest/exemplary/pmp-removal-test.json b/adapters/rtbhouse/rtbhousetest/exemplary/pmp-removal-test.json new file mode 100644 index 00000000000..787f44fd4c2 --- /dev/null +++ b/adapters/rtbhouse/rtbhousetest/exemplary/pmp-removal-test.json @@ -0,0 +1,117 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ] + }, + "pmp": { + "deals": [ + { + "id": "deal-id-1", + "bidfloor": 5.00, + "bidfloorcur": "USD" + } + ] + }, + "ext": { + "bidder": { + "publisherId": "12345" + } + } + } + ] + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://localhost/prebid_server", + "body": { + "id": "test-request-id", + "cur": [ + "USD" + ], + "imp": [ + { + "banner": { + "format": [ + { + "h": 250, + "w": 300 + } + ] + }, + "ext": { + "bidder": { + "publisherId": "12345" + } + }, + "id": "test-imp-id" + } + ], + "site": { + "publisher": { + "id": "12345" + } + } + }, + "impIDs":["test-imp-id"] + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-response-id", + "cur": "USD", + "seatbid": [ + { + "seat": "rtbhouse", + "bid": [ + { + "id": "randomid", + "impid": "test-imp-id", + "price": 300, + "adid": "12345678", + "adm": "some-test-ad", + "cid": "987", + "crid": "12345678", + "h": 250, + "w": 300, + "mtype": 1 + } + ] + } + ] + } + } + } + ], + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "id": "randomid", + "impid": "test-imp-id", + "price": 300, + "adid": "12345678", + "adm": "some-test-ad", + "cid": "987", + "crid": "12345678", + "h": 250, + "w": 300, + "mtype": 1 + }, + "type": "banner" + } + ] + } + ] +} \ No newline at end of file diff --git a/adapters/rtbhouse/rtbhousetest/exemplary/two-bidfloors-given-param-and-impbidfloor.json b/adapters/rtbhouse/rtbhousetest/exemplary/two-bidfloors-given-param-and-impbidfloor.json index 7b9ebf9685e..2e3fcb1bbef 100644 --- a/adapters/rtbhouse/rtbhousetest/exemplary/two-bidfloors-given-param-and-impbidfloor.json +++ b/adapters/rtbhouse/rtbhousetest/exemplary/two-bidfloors-given-param-and-impbidfloor.json @@ -65,6 +65,11 @@ "id": "test-imp-id" } ], + "site": { + "publisher": { + "id": "12345" + } + }, "ext": { "prebid": { "currency": { diff --git a/adapters/rtbhouse/rtbhousetest/supplemental/malformed-imp-ext.json b/adapters/rtbhouse/rtbhousetest/supplemental/malformed-imp-ext.json new file mode 100644 index 00000000000..655f71899ea --- /dev/null +++ b/adapters/rtbhouse/rtbhousetest/supplemental/malformed-imp-ext.json @@ -0,0 +1,25 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ] + }, + "ext": "invalid-json" + } + ] + }, + "expectedMakeRequestsErrors": [ + { + "value": "Bidder extension not provided or can't be unmarshalled", + "comparison": "literal" + } + ] +} \ No newline at end of file From efc7bf445886e2afcf15162976b1b13d653168ba Mon Sep 17 00:00:00 2001 From: Piotr Jaworski Date: Wed, 22 Oct 2025 10:29:39 +0200 Subject: [PATCH 2/3] RTBHouse: changed target location for publisherId --- adapters/rtbhouse/rtbhouse.go | 33 +++++++++++++++++-- .../exemplary/ae-igs-removal.json | 6 +++- .../exemplary/app-with-publisher.json | 6 +++- .../bidfloor-as-bidder-param-without-cur.json | 6 +++- .../exemplary/bidfloor-as-bidder-param.json | 6 +++- .../bidfloor-as-impbidfloor-with-cur.json | 6 +++- .../bidfloor-as-impbidfloor-without-cur.json | 6 +++- .../existing-site-publisher-override.json | 9 +++-- .../multiple-imps-different-publishers.json | 6 +++- .../exemplary/pmp-removal-test.json | 6 +++- ...bidfloors-given-param-and-impbidfloor.json | 6 +++- 11 files changed, 83 insertions(+), 13 deletions(-) diff --git a/adapters/rtbhouse/rtbhouse.go b/adapters/rtbhouse/rtbhouse.go index c0e472da4fc..1773cf9f576 100644 --- a/adapters/rtbhouse/rtbhouse.go +++ b/adapters/rtbhouse/rtbhouse.go @@ -21,6 +21,16 @@ const ( BidderCurrency string = "USD" ) +// publisherExtPrebid defines the structure for publisher.ext.prebid used by RTBHouse adapter +type publisherExtPrebid struct { + PublisherId string `json:"publisherId,omitempty"` +} + +// publisherExt defines the structure for publisher.ext used by RTBHouse adapter +type publisherExt struct { + Prebid *publisherExtPrebid `json:"prebid,omitempty"` +} + // RTBHouseAdapter implements the Bidder interface. type RTBHouseAdapter struct { endpoint string @@ -107,7 +117,7 @@ func (adapter *RTBHouseAdapter) MakeRequests( reqCopy.Imp = append(reqCopy.Imp, imp) } - // Set publisher ID in site.publisher.id if we found one + // Set publisher ID in site.publisher.ext.prebid.publisherId if we found one if publisherId != "" { if reqCopy.Site == nil { reqCopy.Site = &openrtb2.Site{} @@ -123,7 +133,26 @@ func (adapter *RTBHouseAdapter) MakeRequests( publisherCopy := *reqCopy.Site.Publisher reqCopy.Site.Publisher = &publisherCopy } - reqCopy.Site.Publisher.ID = publisherId + + // Set publisherId in publisher.ext.prebid.publisherId using local struct + var pubExt publisherExt + if reqCopy.Site.Publisher.Ext != nil { + if err := jsonutil.Unmarshal(reqCopy.Site.Publisher.Ext, &pubExt); err != nil { + errs = append(errs, err) + return nil, errs + } + } + if pubExt.Prebid == nil { + pubExt.Prebid = &publisherExtPrebid{} + } + pubExt.Prebid.PublisherId = publisherId + + publisherExtJSON, err := jsonutil.Marshal(pubExt) + if err != nil { + errs = append(errs, err) + return nil, errs + } + reqCopy.Site.Publisher.Ext = publisherExtJSON } openRTBRequestJSON, err := json.Marshal(reqCopy) diff --git a/adapters/rtbhouse/rtbhousetest/exemplary/ae-igs-removal.json b/adapters/rtbhouse/rtbhousetest/exemplary/ae-igs-removal.json index 31422c65efa..7cf35414aa0 100644 --- a/adapters/rtbhouse/rtbhousetest/exemplary/ae-igs-removal.json +++ b/adapters/rtbhouse/rtbhousetest/exemplary/ae-igs-removal.json @@ -55,7 +55,11 @@ ], "site": { "publisher": { - "id": "12345" + "ext": { + "prebid": { + "publisherId": "12345" + } + } } } }, diff --git a/adapters/rtbhouse/rtbhousetest/exemplary/app-with-publisher.json b/adapters/rtbhouse/rtbhousetest/exemplary/app-with-publisher.json index 5cbeca115c2..9926dcee630 100644 --- a/adapters/rtbhouse/rtbhousetest/exemplary/app-with-publisher.json +++ b/adapters/rtbhouse/rtbhousetest/exemplary/app-with-publisher.json @@ -57,7 +57,11 @@ ], "site": { "publisher": { - "id": "app-publisher-123" + "ext": { + "prebid": { + "publisherId": "app-publisher-123" + } + } } } }, diff --git a/adapters/rtbhouse/rtbhousetest/exemplary/bidfloor-as-bidder-param-without-cur.json b/adapters/rtbhouse/rtbhousetest/exemplary/bidfloor-as-bidder-param-without-cur.json index f8db7dec760..d31110cb3ef 100644 --- a/adapters/rtbhouse/rtbhousetest/exemplary/bidfloor-as-bidder-param-without-cur.json +++ b/adapters/rtbhouse/rtbhousetest/exemplary/bidfloor-as-bidder-param-without-cur.json @@ -65,7 +65,11 @@ ], "site": { "publisher": { - "id": "12345" + "ext": { + "prebid": { + "publisherId": "12345" + } + } } }, "ext": { diff --git a/adapters/rtbhouse/rtbhousetest/exemplary/bidfloor-as-bidder-param.json b/adapters/rtbhouse/rtbhousetest/exemplary/bidfloor-as-bidder-param.json index 4da3eaa132c..fd324fb0345 100644 --- a/adapters/rtbhouse/rtbhousetest/exemplary/bidfloor-as-bidder-param.json +++ b/adapters/rtbhouse/rtbhousetest/exemplary/bidfloor-as-bidder-param.json @@ -68,7 +68,11 @@ ], "site": { "publisher": { - "id": "12345" + "ext": { + "prebid": { + "publisherId": "12345" + } + } } }, "ext": { diff --git a/adapters/rtbhouse/rtbhousetest/exemplary/bidfloor-as-impbidfloor-with-cur.json b/adapters/rtbhouse/rtbhousetest/exemplary/bidfloor-as-impbidfloor-with-cur.json index 7520c3b6c92..24cc0822dde 100644 --- a/adapters/rtbhouse/rtbhousetest/exemplary/bidfloor-as-impbidfloor-with-cur.json +++ b/adapters/rtbhouse/rtbhousetest/exemplary/bidfloor-as-impbidfloor-with-cur.json @@ -65,7 +65,11 @@ ], "site": { "publisher": { - "id": "12345" + "ext": { + "prebid": { + "publisherId": "12345" + } + } } }, "ext": { diff --git a/adapters/rtbhouse/rtbhousetest/exemplary/bidfloor-as-impbidfloor-without-cur.json b/adapters/rtbhouse/rtbhousetest/exemplary/bidfloor-as-impbidfloor-without-cur.json index 680daecd5ba..e579017c079 100644 --- a/adapters/rtbhouse/rtbhousetest/exemplary/bidfloor-as-impbidfloor-without-cur.json +++ b/adapters/rtbhouse/rtbhousetest/exemplary/bidfloor-as-impbidfloor-without-cur.json @@ -63,7 +63,11 @@ ], "site": { "publisher": { - "id": "12345" + "ext": { + "prebid": { + "publisherId": "12345" + } + } } }, "ext": { diff --git a/adapters/rtbhouse/rtbhousetest/exemplary/existing-site-publisher-override.json b/adapters/rtbhouse/rtbhousetest/exemplary/existing-site-publisher-override.json index db990523a56..235e2c4a8bb 100644 --- a/adapters/rtbhouse/rtbhousetest/exemplary/existing-site-publisher-override.json +++ b/adapters/rtbhouse/rtbhousetest/exemplary/existing-site-publisher-override.json @@ -39,8 +39,13 @@ "site": { "page": "https://example.com", "publisher": { - "id": "new-publisher-123", - "name": "Existing Publisher" + "id": "existing-publisher", + "name": "Existing Publisher", + "ext": { + "prebid": { + "publisherId": "new-publisher-123" + } + } } }, "imp": [ diff --git a/adapters/rtbhouse/rtbhousetest/exemplary/multiple-imps-different-publishers.json b/adapters/rtbhouse/rtbhousetest/exemplary/multiple-imps-different-publishers.json index 4ce3baa26d9..3cb44d54220 100644 --- a/adapters/rtbhouse/rtbhousetest/exemplary/multiple-imps-different-publishers.json +++ b/adapters/rtbhouse/rtbhousetest/exemplary/multiple-imps-different-publishers.json @@ -81,7 +81,11 @@ ], "site": { "publisher": { - "id": "first-publisher" + "ext": { + "prebid": { + "publisherId": "first-publisher" + } + } } } }, diff --git a/adapters/rtbhouse/rtbhousetest/exemplary/pmp-removal-test.json b/adapters/rtbhouse/rtbhousetest/exemplary/pmp-removal-test.json index 787f44fd4c2..0d31ef3d5b7 100644 --- a/adapters/rtbhouse/rtbhousetest/exemplary/pmp-removal-test.json +++ b/adapters/rtbhouse/rtbhousetest/exemplary/pmp-removal-test.json @@ -58,7 +58,11 @@ ], "site": { "publisher": { - "id": "12345" + "ext": { + "prebid": { + "publisherId": "12345" + } + } } } }, diff --git a/adapters/rtbhouse/rtbhousetest/exemplary/two-bidfloors-given-param-and-impbidfloor.json b/adapters/rtbhouse/rtbhousetest/exemplary/two-bidfloors-given-param-and-impbidfloor.json index 2e3fcb1bbef..71b95d18db8 100644 --- a/adapters/rtbhouse/rtbhousetest/exemplary/two-bidfloors-given-param-and-impbidfloor.json +++ b/adapters/rtbhouse/rtbhousetest/exemplary/two-bidfloors-given-param-and-impbidfloor.json @@ -67,7 +67,11 @@ ], "site": { "publisher": { - "id": "12345" + "ext": { + "prebid": { + "publisherId": "12345" + } + } } }, "ext": { From d8a96898b87e02ce23037d3a94339f14956a2d6c Mon Sep 17 00:00:00 2001 From: Piotr Jaworski Date: Thu, 30 Oct 2025 10:28:51 +0100 Subject: [PATCH 3/3] RTBHouse: add App support for publisherId extraction --- adapters/rtbhouse/rtbhouse.go | 88 ++++++++++++------- .../exemplary/app-with-publisher.json | 20 ++--- 2 files changed, 65 insertions(+), 43 deletions(-) diff --git a/adapters/rtbhouse/rtbhouse.go b/adapters/rtbhouse/rtbhouse.go index 1773cf9f576..c6445f1f154 100644 --- a/adapters/rtbhouse/rtbhouse.go +++ b/adapters/rtbhouse/rtbhouse.go @@ -117,42 +117,12 @@ func (adapter *RTBHouseAdapter) MakeRequests( reqCopy.Imp = append(reqCopy.Imp, imp) } - // Set publisher ID in site.publisher.ext.prebid.publisherId if we found one + // Set publisher ID in site.publisher.ext.prebid.publisherId or app.publisher.ext.prebid.publisherId if we found one if publisherId != "" { - if reqCopy.Site == nil { - reqCopy.Site = &openrtb2.Site{} - } else { - // Create a copy of the site to avoid modifying the original request - siteCopy := *reqCopy.Site - reqCopy.Site = &siteCopy - } - if reqCopy.Site.Publisher == nil { - reqCopy.Site.Publisher = &openrtb2.Publisher{} - } else { - // Create a copy of the publisher to avoid modifying the original request - publisherCopy := *reqCopy.Site.Publisher - reqCopy.Site.Publisher = &publisherCopy - } - - // Set publisherId in publisher.ext.prebid.publisherId using local struct - var pubExt publisherExt - if reqCopy.Site.Publisher.Ext != nil { - if err := jsonutil.Unmarshal(reqCopy.Site.Publisher.Ext, &pubExt); err != nil { - errs = append(errs, err) - return nil, errs - } - } - if pubExt.Prebid == nil { - pubExt.Prebid = &publisherExtPrebid{} - } - pubExt.Prebid.PublisherId = publisherId - - publisherExtJSON, err := jsonutil.Marshal(pubExt) - if err != nil { + if err := setPublisherID(&reqCopy, publisherId); err != nil { errs = append(errs, err) return nil, errs } - reqCopy.Site.Publisher.Ext = publisherExtJSON } openRTBRequestJSON, err := json.Marshal(reqCopy) @@ -175,6 +145,60 @@ func (adapter *RTBHouseAdapter) MakeRequests( return requestsToBidder, errs } +// setPublisherID sets the publisherId in site.publisher.ext.prebid.publisherId or app.publisher.ext.prebid.publisherId +func setPublisherID(request *openrtb2.BidRequest, publisherId string) error { + var publisher *openrtb2.Publisher + if request.Site != nil { + // Create a copy of the site to avoid modifying the original request + siteCopy := *request.Site + request.Site = &siteCopy + publisher = request.Site.Publisher + } else if request.App != nil { + // Create a copy of the app to avoid modifying the original request + appCopy := *request.App + request.App = &appCopy + publisher = request.App.Publisher + } else { + // If neither site nor app exists, create a site object + request.Site = &openrtb2.Site{} + } + + if publisher != nil { + // Create a copy of the publisher to avoid modifying the original request + publisherCopy := *publisher + publisher = &publisherCopy + } else { + publisher = &openrtb2.Publisher{} + } + + // Set publisherId in publisher.ext.prebid.publisherId using local struct + var pubExt publisherExt + if publisher.Ext != nil { + if err := jsonutil.Unmarshal(publisher.Ext, &pubExt); err != nil { + return err + } + } + if pubExt.Prebid == nil { + pubExt.Prebid = &publisherExtPrebid{} + } + pubExt.Prebid.PublisherId = publisherId + + publisherExtJSON, err := jsonutil.Marshal(pubExt) + if err != nil { + return err + } + publisher.Ext = publisherExtJSON + + // Assign the updated publisher back to the appropriate object + if request.Site != nil { + request.Site.Publisher = publisher + } else if request.App != nil { + request.App.Publisher = publisher + } + + return nil +} + func clearAuctionEnvironment(imp *openrtb2.Imp) (json.RawMessage, error) { var objmap map[string]interface{} err := json.Unmarshal(imp.Ext, &objmap) diff --git a/adapters/rtbhouse/rtbhousetest/exemplary/app-with-publisher.json b/adapters/rtbhouse/rtbhousetest/exemplary/app-with-publisher.json index 9926dcee630..d53ab37f2d5 100644 --- a/adapters/rtbhouse/rtbhousetest/exemplary/app-with-publisher.json +++ b/adapters/rtbhouse/rtbhousetest/exemplary/app-with-publisher.json @@ -35,7 +35,14 @@ ], "app": { "bundle": "com.example.app", - "name": "Test App" + "name": "Test App", + "publisher": { + "ext": { + "prebid": { + "publisherId": "app-publisher-123" + } + } + } }, "imp": [ { @@ -54,16 +61,7 @@ }, "id": "test-imp-id" } - ], - "site": { - "publisher": { - "ext": { - "prebid": { - "publisherId": "app-publisher-123" - } - } - } - } + ] }, "impIDs": ["test-imp-id"] },