From 58dcfd18cc6686407b33af2370d2d6342700d3d2 Mon Sep 17 00:00:00 2001 From: Piotr Jaworski Date: Mon, 1 Dec 2025 17:26:58 +0100 Subject: [PATCH 1/7] RTBHouse: Enhance TagID handling and add new test cases --- adapters/rtbhouse/rtbhouse.go | 82 ++++++++---- .../exemplary/ae-igs-removal.json | 3 +- .../exemplary/app-with-publisher.json | 3 +- .../rtbhousetest/exemplary/app_banner.json | 3 +- .../rtbhousetest/exemplary/app_native.json | 3 +- .../exemplary/banner-resolve-macros.json | 3 +- .../bidfloor-as-bidder-param-without-cur.json | 3 +- .../exemplary/bidfloor-as-bidder-param.json | 3 +- .../bidfloor-as-impbidfloor-with-cur.json | 3 +- .../bidfloor-as-impbidfloor-without-cur.json | 3 +- .../existing-site-publisher-override.json | 3 +- .../multiple-imps-different-publishers.json | 6 +- .../native-with-deprecated-native-prop.json | 3 +- .../native-with-proper-native-response.json | 3 +- .../exemplary/pmp-removal-test.json | 3 +- .../exemplary/simple-banner-paapi.json | 3 +- .../rtbhousetest/exemplary/simple-banner.json | 3 +- .../exemplary/tagid-from-pbadslot.json | 119 +++++++++++++++++ .../tagid-precedence-gpid-over-pbadslot.json | 122 ++++++++++++++++++ .../tagid-preservation-existing.json | 116 +++++++++++++++++ ...bidfloors-given-param-and-impbidfloor.json | 3 +- .../supplemental/bad_response.json | 3 +- ...ner-native-req-faulty-mtype-in-native.json | 6 +- .../native-with-faulty-adm-native-prop.json | 3 +- .../native-with-faulty-adm-response.json | 3 +- .../supplemental/simple-banner-bad-mtype.json | 3 +- .../supplemental/simple-banner-no-mtype.json | 3 +- .../rtbhousetest/supplemental/status_204.json | 3 +- .../rtbhousetest/supplemental/status_400.json | 3 +- .../rtbhousetest/supplemental/status_418.json | 3 +- 30 files changed, 472 insertions(+), 51 deletions(-) create mode 100644 adapters/rtbhouse/rtbhousetest/exemplary/tagid-from-pbadslot.json create mode 100644 adapters/rtbhouse/rtbhousetest/exemplary/tagid-precedence-gpid-over-pbadslot.json create mode 100644 adapters/rtbhouse/rtbhousetest/exemplary/tagid-preservation-existing.json diff --git a/adapters/rtbhouse/rtbhouse.go b/adapters/rtbhouse/rtbhouse.go index c6445f1f154..377f2204f14 100644 --- a/adapters/rtbhouse/rtbhouse.go +++ b/adapters/rtbhouse/rtbhouse.go @@ -59,7 +59,15 @@ func (adapter *RTBHouseAdapter) MakeRequests( var publisherId string for _, imp := range openRTBRequest.Imp { - rtbhouseExt, err := getImpressionExt(imp) + impExtMap := make(map[string]interface{}) + err := json.Unmarshal(imp.Ext, &impExtMap) + if err != nil { + return nil, []error{&errortypes.BadInput{ + Message: "Bidder extension not provided or can't be unmarshalled", + }} + } + + rtbhouseExt, err := getImpressionExt(impExtMap) if err != nil { return nil, []error{err} } @@ -100,9 +108,17 @@ func (adapter *RTBHouseAdapter) MakeRequests( imp.BidFloor = bidFloor } - // remove PAAPI signals from imp.Ext. RTB House pauses PAAPI support, - // the bidder should not get any PAAPI signals - newImpExt, err := clearAuctionEnvironment(&imp) + if imp.TagID == "" { + imp.TagID = getTagIDFromImpExt(impExtMap, imp.ID) + } + + // Process imp.Ext: remove PAAPI signals and assign TagID + err = clearAuctionEnvironment(impExtMap) + if err != nil { + errs = append(errs, err) + return nil, errs + } + newImpExt, err := json.Marshal(impExtMap) if err != nil { errs = append(errs, err) return nil, errs @@ -199,44 +215,64 @@ func setPublisherID(request *openrtb2.BidRequest, publisherId string) error { return nil } -func clearAuctionEnvironment(imp *openrtb2.Imp) (json.RawMessage, error) { - var objmap map[string]interface{} - err := json.Unmarshal(imp.Ext, &objmap) - if err != nil { - return nil, err - } - +func clearAuctionEnvironment(impExtMap map[string]interface{}) error { keysToDelete := []string{"ae", "igs", "paapi"} for _, key := range keysToDelete { - _, exists := objmap[key] - if exists { - delete(objmap, key) + delete(impExtMap, key) + } + return nil +} + +func getTagIDFromImpExt(impExtMap map[string]interface{}, impID string) string { + // Try to get TagID from imp.ext.gpid + if gpid, ok := impExtMap["gpid"].(string); ok && gpid != "" { + return gpid + } + + // Try to get TagID from imp.ext.data.pbAdSlot + if data, ok := impExtMap["data"].(map[string]interface{}); ok { + if pbAdSlot, ok := data["pbadslot"].(string); ok && pbAdSlot != "" { + return pbAdSlot } } - newImpExt, err := json.Marshal(objmap) - if err != nil { - return nil, err + // If not found, use imp.ID as fallback + if impID != "" { + return impID } - return newImpExt, nil + return "" } -func getImpressionExt(imp openrtb2.Imp) (*openrtb_ext.ExtImpRTBHouse, error) { - var bidderExt adapters.ExtImpBidder - if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { +func getImpressionExt(impExtMap map[string]interface{}) (*openrtb_ext.ExtImpRTBHouse, error) { + var bidderVal interface{} + var found bool + + // Check for bidder parameters in imp.ext.bidder + if val, ok := impExtMap["bidder"]; ok { + bidderVal = val + found = true + } + + if !found { + return nil, &errortypes.BadInput{ + Message: "Bidder extension not provided or can't be unmarshalled", + } + } + + bidderBytes, err := json.Marshal(bidderVal) + if err != nil { return nil, &errortypes.BadInput{ Message: "Bidder extension not provided or can't be unmarshalled", } } var rtbhouseExt openrtb_ext.ExtImpRTBHouse - if err := jsonutil.Unmarshal(bidderExt.Bidder, &rtbhouseExt); err != nil { + if err := jsonutil.Unmarshal(bidderBytes, &rtbhouseExt); err != nil { return nil, &errortypes.BadInput{ Message: "Error while unmarshaling bidder extension", } } - return &rtbhouseExt, nil } diff --git a/adapters/rtbhouse/rtbhousetest/exemplary/ae-igs-removal.json b/adapters/rtbhouse/rtbhousetest/exemplary/ae-igs-removal.json index 7cf35414aa0..bfb2c55af5e 100644 --- a/adapters/rtbhouse/rtbhousetest/exemplary/ae-igs-removal.json +++ b/adapters/rtbhouse/rtbhousetest/exemplary/ae-igs-removal.json @@ -36,6 +36,7 @@ ], "imp": [ { + "id": "test-imp-id", "banner": { "format": [ { @@ -50,7 +51,7 @@ }, "someOtherField": "should-remain" }, - "id": "test-imp-id" + "tagid": "test-imp-id" } ], "site": { diff --git a/adapters/rtbhouse/rtbhousetest/exemplary/app-with-publisher.json b/adapters/rtbhouse/rtbhousetest/exemplary/app-with-publisher.json index d53ab37f2d5..6ccac250983 100644 --- a/adapters/rtbhouse/rtbhousetest/exemplary/app-with-publisher.json +++ b/adapters/rtbhouse/rtbhousetest/exemplary/app-with-publisher.json @@ -59,7 +59,8 @@ "publisherId": "app-publisher-123" } }, - "id": "test-imp-id" + "id": "test-imp-id", + "tagid": "test-imp-id" } ] }, diff --git a/adapters/rtbhouse/rtbhousetest/exemplary/app_banner.json b/adapters/rtbhouse/rtbhousetest/exemplary/app_banner.json index ba14e50d88d..8a39951ee9f 100644 --- a/adapters/rtbhouse/rtbhousetest/exemplary/app_banner.json +++ b/adapters/rtbhouse/rtbhousetest/exemplary/app_banner.json @@ -49,7 +49,8 @@ }, "ext": { "bidder": {} - } + }, + "tagid": "test-imp-id" }] }, "impIDs":["test-imp-id"] diff --git a/adapters/rtbhouse/rtbhousetest/exemplary/app_native.json b/adapters/rtbhouse/rtbhousetest/exemplary/app_native.json index bdd5e573504..272a10f5a1d 100644 --- a/adapters/rtbhouse/rtbhousetest/exemplary/app_native.json +++ b/adapters/rtbhouse/rtbhousetest/exemplary/app_native.json @@ -43,7 +43,8 @@ }, "ext": { "bidder": {} - } + }, + "tagid": "test-native-imp" } ], "app": { diff --git a/adapters/rtbhouse/rtbhousetest/exemplary/banner-resolve-macros.json b/adapters/rtbhouse/rtbhousetest/exemplary/banner-resolve-macros.json index eaa3965040e..55c054d5452 100644 --- a/adapters/rtbhouse/rtbhousetest/exemplary/banner-resolve-macros.json +++ b/adapters/rtbhouse/rtbhousetest/exemplary/banner-resolve-macros.json @@ -37,7 +37,8 @@ }, "ext": { "bidder": {} - } + }, + "tagid": "test-imp-id" }] }, "impIDs":["test-imp-id"] 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 d31110cb3ef..a9ede9271ec 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 @@ -60,7 +60,8 @@ "bidfloor": 3.00 } }, - "id": "test-imp-id" + "id": "test-imp-id", + "tagid": "test-imp-id" } ], "site": { diff --git a/adapters/rtbhouse/rtbhousetest/exemplary/bidfloor-as-bidder-param.json b/adapters/rtbhouse/rtbhousetest/exemplary/bidfloor-as-bidder-param.json index fd324fb0345..bdc7eed6bec 100644 --- a/adapters/rtbhouse/rtbhousetest/exemplary/bidfloor-as-bidder-param.json +++ b/adapters/rtbhouse/rtbhousetest/exemplary/bidfloor-as-bidder-param.json @@ -63,7 +63,8 @@ "bidfloor": 2 } }, - "id": "test-imp-id" + "id": "test-imp-id", + "tagid": "test-imp-id" } ], "site": { 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 24cc0822dde..97c9f2e59cf 100644 --- a/adapters/rtbhouse/rtbhousetest/exemplary/bidfloor-as-impbidfloor-with-cur.json +++ b/adapters/rtbhouse/rtbhousetest/exemplary/bidfloor-as-impbidfloor-with-cur.json @@ -60,7 +60,8 @@ "publisherId": "12345" } }, - "id": "test-imp-id" + "id": "test-imp-id", + "tagid": "test-imp-id" } ], "site": { 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 e579017c079..139a492ce51 100644 --- a/adapters/rtbhouse/rtbhousetest/exemplary/bidfloor-as-impbidfloor-without-cur.json +++ b/adapters/rtbhouse/rtbhousetest/exemplary/bidfloor-as-impbidfloor-without-cur.json @@ -58,7 +58,8 @@ "publisherId": "12345" } }, - "id": "test-imp-id" + "id": "test-imp-id", + "tagid": "test-imp-id" } ], "site": { diff --git a/adapters/rtbhouse/rtbhousetest/exemplary/existing-site-publisher-override.json b/adapters/rtbhouse/rtbhousetest/exemplary/existing-site-publisher-override.json index 235e2c4a8bb..a45e84bb7ba 100644 --- a/adapters/rtbhouse/rtbhousetest/exemplary/existing-site-publisher-override.json +++ b/adapters/rtbhouse/rtbhousetest/exemplary/existing-site-publisher-override.json @@ -63,7 +63,8 @@ "publisherId": "new-publisher-123" } }, - "id": "test-imp-id" + "id": "test-imp-id", + "tagid": "test-imp-id" } ] }, diff --git a/adapters/rtbhouse/rtbhousetest/exemplary/multiple-imps-different-publishers.json b/adapters/rtbhouse/rtbhousetest/exemplary/multiple-imps-different-publishers.json index 3cb44d54220..70cfc797b36 100644 --- a/adapters/rtbhouse/rtbhousetest/exemplary/multiple-imps-different-publishers.json +++ b/adapters/rtbhouse/rtbhousetest/exemplary/multiple-imps-different-publishers.json @@ -60,7 +60,8 @@ "publisherId": "first-publisher" } }, - "id": "test-imp-id-1" + "id": "test-imp-id-1", + "tagid": "test-imp-id-1" }, { "banner": { @@ -76,7 +77,8 @@ "publisherId": "second-publisher" } }, - "id": "test-imp-id-2" + "id": "test-imp-id-2", + "tagid": "test-imp-id-2" } ], "site": { diff --git a/adapters/rtbhouse/rtbhousetest/exemplary/native-with-deprecated-native-prop.json b/adapters/rtbhouse/rtbhousetest/exemplary/native-with-deprecated-native-prop.json index a4aa158053b..ca898872a61 100644 --- a/adapters/rtbhouse/rtbhousetest/exemplary/native-with-deprecated-native-prop.json +++ b/adapters/rtbhouse/rtbhousetest/exemplary/native-with-deprecated-native-prop.json @@ -37,7 +37,8 @@ }, "ext": { "bidder": {} - } + }, + "tagid": "test-native-imp" } ], "site": { diff --git a/adapters/rtbhouse/rtbhousetest/exemplary/native-with-proper-native-response.json b/adapters/rtbhouse/rtbhousetest/exemplary/native-with-proper-native-response.json index 232a102ce74..5f5f6f1a2c8 100644 --- a/adapters/rtbhouse/rtbhousetest/exemplary/native-with-proper-native-response.json +++ b/adapters/rtbhouse/rtbhousetest/exemplary/native-with-proper-native-response.json @@ -37,7 +37,8 @@ }, "ext": { "bidder": {} - } + }, + "tagid": "test-native-imp" } ], "site": { diff --git a/adapters/rtbhouse/rtbhousetest/exemplary/pmp-removal-test.json b/adapters/rtbhouse/rtbhousetest/exemplary/pmp-removal-test.json index 0d31ef3d5b7..3b05d5c5872 100644 --- a/adapters/rtbhouse/rtbhousetest/exemplary/pmp-removal-test.json +++ b/adapters/rtbhouse/rtbhousetest/exemplary/pmp-removal-test.json @@ -53,7 +53,8 @@ "publisherId": "12345" } }, - "id": "test-imp-id" + "id": "test-imp-id", + "tagid": "test-imp-id" } ], "site": { diff --git a/adapters/rtbhouse/rtbhousetest/exemplary/simple-banner-paapi.json b/adapters/rtbhouse/rtbhousetest/exemplary/simple-banner-paapi.json index fb96bdff14d..1a561ab5737 100644 --- a/adapters/rtbhouse/rtbhousetest/exemplary/simple-banner-paapi.json +++ b/adapters/rtbhouse/rtbhousetest/exemplary/simple-banner-paapi.json @@ -45,7 +45,8 @@ }, "ext": { "bidder": {} - } + }, + "tagid": "test-imp-id" }] }, "impIDs":["test-imp-id"] diff --git a/adapters/rtbhouse/rtbhousetest/exemplary/simple-banner.json b/adapters/rtbhouse/rtbhousetest/exemplary/simple-banner.json index 0cad5a6b96f..61923eb38ef 100644 --- a/adapters/rtbhouse/rtbhousetest/exemplary/simple-banner.json +++ b/adapters/rtbhouse/rtbhousetest/exemplary/simple-banner.json @@ -37,7 +37,8 @@ }, "ext": { "bidder": {} - } + }, + "tagid": "test-imp-id" }] }, "impIDs":["test-imp-id"] diff --git a/adapters/rtbhouse/rtbhousetest/exemplary/tagid-from-pbadslot.json b/adapters/rtbhouse/rtbhousetest/exemplary/tagid-from-pbadslot.json new file mode 100644 index 00000000000..2fa29887644 --- /dev/null +++ b/adapters/rtbhouse/rtbhousetest/exemplary/tagid-from-pbadslot.json @@ -0,0 +1,119 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ] + }, + "ext": { + "data": { + "pbadslot": "pbslot_value" + }, + "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" + }, + "data": { + "pbadslot": "pbslot_value" + } + }, + "id": "test-imp-id", + "tagid": "pbslot_value" + } + ], + "site": { + "publisher": { + "ext": { + "prebid": { + "publisherId": "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/tagid-precedence-gpid-over-pbadslot.json b/adapters/rtbhouse/rtbhousetest/exemplary/tagid-precedence-gpid-over-pbadslot.json new file mode 100644 index 00000000000..9e4e35debfc --- /dev/null +++ b/adapters/rtbhouse/rtbhousetest/exemplary/tagid-precedence-gpid-over-pbadslot.json @@ -0,0 +1,122 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "tagid": "", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ] + }, + "ext": { + "gpid": "gpid_value", + "data": { + "pbAdSlot": "pbslot_value" + }, + "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" + }, + "gpid": "gpid_value", + "data": { + "pbAdSlot": "pbslot_value" + } + }, + "id": "test-imp-id", + "tagid": "gpid_value" + } + ], + "site": { + "publisher": { + "ext": { + "prebid": { + "publisherId": "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/tagid-preservation-existing.json b/adapters/rtbhouse/rtbhousetest/exemplary/tagid-preservation-existing.json new file mode 100644 index 00000000000..785991f05b7 --- /dev/null +++ b/adapters/rtbhouse/rtbhousetest/exemplary/tagid-preservation-existing.json @@ -0,0 +1,116 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "tagid": "existing_tag", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ] + }, + "ext": { + "gpid": "gpid_value", + "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" + }, + "gpid": "gpid_value" + }, + "id": "test-imp-id", + "tagid": "existing_tag" + } + ], + "site": { + "publisher": { + "ext": { + "prebid": { + "publisherId": "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 71b95d18db8..e1389acece5 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 @@ -62,7 +62,8 @@ "bidfloor": 2 } }, - "id": "test-imp-id" + "id": "test-imp-id", + "tagid": "test-imp-id" } ], "site": { diff --git a/adapters/rtbhouse/rtbhousetest/supplemental/bad_response.json b/adapters/rtbhouse/rtbhousetest/supplemental/bad_response.json index a2d0c8da3d4..dc61c6d0615 100644 --- a/adapters/rtbhouse/rtbhousetest/supplemental/bad_response.json +++ b/adapters/rtbhouse/rtbhousetest/supplemental/bad_response.json @@ -41,7 +41,8 @@ "ext": { "bidder": { } - } + }, + "tagid": "test-imp-id" } ] }, diff --git a/adapters/rtbhouse/rtbhousetest/supplemental/banner-native-req-faulty-mtype-in-native.json b/adapters/rtbhouse/rtbhousetest/supplemental/banner-native-req-faulty-mtype-in-native.json index 4f643d18427..9229cd58ec1 100644 --- a/adapters/rtbhouse/rtbhousetest/supplemental/banner-native-req-faulty-mtype-in-native.json +++ b/adapters/rtbhouse/rtbhousetest/supplemental/banner-native-req-faulty-mtype-in-native.json @@ -49,7 +49,8 @@ }, "ext": { "bidder": {} - } + }, + "tagid": "test-native-imp" }, { "id": "test-banner-imp", @@ -61,7 +62,8 @@ }, "ext": { "bidder": {} - } + }, + "tagid": "test-banner-imp" } ], "site": { diff --git a/adapters/rtbhouse/rtbhousetest/supplemental/native-with-faulty-adm-native-prop.json b/adapters/rtbhouse/rtbhousetest/supplemental/native-with-faulty-adm-native-prop.json index bfdf568d3c4..99dc0bcbb91 100644 --- a/adapters/rtbhouse/rtbhousetest/supplemental/native-with-faulty-adm-native-prop.json +++ b/adapters/rtbhouse/rtbhousetest/supplemental/native-with-faulty-adm-native-prop.json @@ -37,7 +37,8 @@ }, "ext": { "bidder": {} - } + }, + "tagid": "test-native-imp" } ], "site": { diff --git a/adapters/rtbhouse/rtbhousetest/supplemental/native-with-faulty-adm-response.json b/adapters/rtbhouse/rtbhousetest/supplemental/native-with-faulty-adm-response.json index 4e95d2e23cd..6a1c564e46e 100644 --- a/adapters/rtbhouse/rtbhousetest/supplemental/native-with-faulty-adm-response.json +++ b/adapters/rtbhouse/rtbhousetest/supplemental/native-with-faulty-adm-response.json @@ -37,7 +37,8 @@ }, "ext": { "bidder": {} - } + }, + "tagid": "test-native-imp" } ], "site": { diff --git a/adapters/rtbhouse/rtbhousetest/supplemental/simple-banner-bad-mtype.json b/adapters/rtbhouse/rtbhousetest/supplemental/simple-banner-bad-mtype.json index 3b92e5d8fda..385f807a490 100644 --- a/adapters/rtbhouse/rtbhousetest/supplemental/simple-banner-bad-mtype.json +++ b/adapters/rtbhouse/rtbhousetest/supplemental/simple-banner-bad-mtype.json @@ -46,7 +46,8 @@ }, "ext": { "bidder": {} - } + }, + "tagid": "test-imp-id" } ] }, diff --git a/adapters/rtbhouse/rtbhousetest/supplemental/simple-banner-no-mtype.json b/adapters/rtbhouse/rtbhousetest/supplemental/simple-banner-no-mtype.json index 58bdab87eb9..d73090b0b1d 100644 --- a/adapters/rtbhouse/rtbhousetest/supplemental/simple-banner-no-mtype.json +++ b/adapters/rtbhouse/rtbhousetest/supplemental/simple-banner-no-mtype.json @@ -46,7 +46,8 @@ }, "ext": { "bidder": {} - } + }, + "tagid": "test-imp-id" } ] }, diff --git a/adapters/rtbhouse/rtbhousetest/supplemental/status_204.json b/adapters/rtbhouse/rtbhousetest/supplemental/status_204.json index 03a69c2617f..8258d376987 100644 --- a/adapters/rtbhouse/rtbhousetest/supplemental/status_204.json +++ b/adapters/rtbhouse/rtbhousetest/supplemental/status_204.json @@ -41,7 +41,8 @@ "ext": { "bidder": { } - } + }, + "tagid": "test-imp-id" } ] }, diff --git a/adapters/rtbhouse/rtbhousetest/supplemental/status_400.json b/adapters/rtbhouse/rtbhousetest/supplemental/status_400.json index 25f87786364..06fcf177afd 100644 --- a/adapters/rtbhouse/rtbhousetest/supplemental/status_400.json +++ b/adapters/rtbhouse/rtbhousetest/supplemental/status_400.json @@ -41,7 +41,8 @@ "ext": { "bidder": { } - } + }, + "tagid": "test-imp-id" } ] }, diff --git a/adapters/rtbhouse/rtbhousetest/supplemental/status_418.json b/adapters/rtbhouse/rtbhousetest/supplemental/status_418.json index 27073b0e0c6..f27138969d0 100644 --- a/adapters/rtbhouse/rtbhousetest/supplemental/status_418.json +++ b/adapters/rtbhouse/rtbhousetest/supplemental/status_418.json @@ -41,7 +41,8 @@ "ext": { "bidder": { } - } + }, + "tagid": "test-imp-id" } ] }, From a29a2da2e7124314eed1c3c02984550f3d5ef37a Mon Sep 17 00:00:00 2001 From: Piotr Jaworski Date: Tue, 2 Dec 2025 15:38:04 +0100 Subject: [PATCH 2/7] RTBHouse: Add TagID extraction from adserver.adslot and new test case --- adapters/rtbhouse/rtbhouse.go | 20 ++- .../exemplary/tagid-from-adserver-adslot.json | 123 ++++++++++++++++++ 2 files changed, 137 insertions(+), 6 deletions(-) create mode 100644 adapters/rtbhouse/rtbhousetest/exemplary/tagid-from-adserver-adslot.json diff --git a/adapters/rtbhouse/rtbhouse.go b/adapters/rtbhouse/rtbhouse.go index 377f2204f14..af5a552c63f 100644 --- a/adapters/rtbhouse/rtbhouse.go +++ b/adapters/rtbhouse/rtbhouse.go @@ -112,7 +112,7 @@ func (adapter *RTBHouseAdapter) MakeRequests( imp.TagID = getTagIDFromImpExt(impExtMap, imp.ID) } - // Process imp.Ext: remove PAAPI signals and assign TagID + // remove PAAPI signals err = clearAuctionEnvironment(impExtMap) if err != nil { errs = append(errs, err) @@ -224,19 +224,27 @@ func clearAuctionEnvironment(impExtMap map[string]interface{}) error { } func getTagIDFromImpExt(impExtMap map[string]interface{}, impID string) string { - // Try to get TagID from imp.ext.gpid + // imp.ext.gpid if gpid, ok := impExtMap["gpid"].(string); ok && gpid != "" { return gpid } - // Try to get TagID from imp.ext.data.pbAdSlot - if data, ok := impExtMap["data"].(map[string]interface{}); ok { - if pbAdSlot, ok := data["pbadslot"].(string); ok && pbAdSlot != "" { + dataMap, hasData := impExtMap["data"].(map[string]interface{}) + if hasData { + // imp.ext.data.adserver.adslot + if adserver, ok := dataMap["adserver"].(map[string]interface{}); ok { + if adslot, ok := adserver["adslot"].(string); ok && adslot != "" { + return adslot + } + } + + // imp.ext.data.pbAdSlot + if pbAdSlot, ok := dataMap["pbadslot"].(string); ok && pbAdSlot != "" { return pbAdSlot } } - // If not found, use imp.ID as fallback + // imp.ID as fallback if impID != "" { return impID } diff --git a/adapters/rtbhouse/rtbhousetest/exemplary/tagid-from-adserver-adslot.json b/adapters/rtbhouse/rtbhousetest/exemplary/tagid-from-adserver-adslot.json new file mode 100644 index 00000000000..e069a1fd84d --- /dev/null +++ b/adapters/rtbhouse/rtbhousetest/exemplary/tagid-from-adserver-adslot.json @@ -0,0 +1,123 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ] + }, + "ext": { + "data": { + "adserver": { + "adslot": "adserver_slot_value" + } + }, + "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" + }, + "data": { + "adserver": { + "adslot": "adserver_slot_value" + } + } + }, + "id": "test-imp-id", + "tagid": "adserver_slot_value" + } + ], + "site": { + "publisher": { + "ext": { + "prebid": { + "publisherId": "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 From 94f705b5d98a5ed28576ebd739fce44055b16830 Mon Sep 17 00:00:00 2001 From: Piotr Jaworski Date: Wed, 3 Dec 2025 14:32:33 +0100 Subject: [PATCH 3/7] RTBHouse: refactor clearAuctionEnvironment function to remove error handling and simplify implementation --- adapters/rtbhouse/rtbhouse.go | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/adapters/rtbhouse/rtbhouse.go b/adapters/rtbhouse/rtbhouse.go index af5a552c63f..79aceec031b 100644 --- a/adapters/rtbhouse/rtbhouse.go +++ b/adapters/rtbhouse/rtbhouse.go @@ -113,11 +113,7 @@ func (adapter *RTBHouseAdapter) MakeRequests( } // remove PAAPI signals - err = clearAuctionEnvironment(impExtMap) - if err != nil { - errs = append(errs, err) - return nil, errs - } + clearAuctionEnvironment(impExtMap) newImpExt, err := json.Marshal(impExtMap) if err != nil { errs = append(errs, err) @@ -215,12 +211,11 @@ func setPublisherID(request *openrtb2.BidRequest, publisherId string) error { return nil } -func clearAuctionEnvironment(impExtMap map[string]interface{}) error { +func clearAuctionEnvironment(impExtMap map[string]interface{}) { keysToDelete := []string{"ae", "igs", "paapi"} for _, key := range keysToDelete { delete(impExtMap, key) } - return nil } func getTagIDFromImpExt(impExtMap map[string]interface{}, impID string) string { From 9cc694248238febb2e08f956a3325867ad861baa Mon Sep 17 00:00:00 2001 From: Piotr Jaworski Date: Wed, 11 Feb 2026 11:38:59 +0100 Subject: [PATCH 4/7] RTBHouse: fixed correct casing in the adapter code and test cases --- adapters/rtbhouse/rtbhouse.go | 13 +++---------- .../tagid-precedence-gpid-over-pbadslot.json | 4 ++-- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/adapters/rtbhouse/rtbhouse.go b/adapters/rtbhouse/rtbhouse.go index 79aceec031b..a7805d9f883 100644 --- a/adapters/rtbhouse/rtbhouse.go +++ b/adapters/rtbhouse/rtbhouse.go @@ -233,7 +233,7 @@ func getTagIDFromImpExt(impExtMap map[string]interface{}, impID string) string { } } - // imp.ext.data.pbAdSlot + // imp.ext.data.pbadslot if pbAdSlot, ok := dataMap["pbadslot"].(string); ok && pbAdSlot != "" { return pbAdSlot } @@ -248,16 +248,9 @@ func getTagIDFromImpExt(impExtMap map[string]interface{}, impID string) string { } func getImpressionExt(impExtMap map[string]interface{}) (*openrtb_ext.ExtImpRTBHouse, error) { - var bidderVal interface{} - var found bool - // Check for bidder parameters in imp.ext.bidder - if val, ok := impExtMap["bidder"]; ok { - bidderVal = val - found = true - } - - if !found { + bidderVal, ok := impExtMap["bidder"] + if !ok { return nil, &errortypes.BadInput{ Message: "Bidder extension not provided or can't be unmarshalled", } diff --git a/adapters/rtbhouse/rtbhousetest/exemplary/tagid-precedence-gpid-over-pbadslot.json b/adapters/rtbhouse/rtbhousetest/exemplary/tagid-precedence-gpid-over-pbadslot.json index 9e4e35debfc..df1b7c3fafd 100644 --- a/adapters/rtbhouse/rtbhousetest/exemplary/tagid-precedence-gpid-over-pbadslot.json +++ b/adapters/rtbhouse/rtbhousetest/exemplary/tagid-precedence-gpid-over-pbadslot.json @@ -16,7 +16,7 @@ "ext": { "gpid": "gpid_value", "data": { - "pbAdSlot": "pbslot_value" + "pbadslot": "pbslot_value" }, "bidder": { "publisherId": "12345" @@ -50,7 +50,7 @@ }, "gpid": "gpid_value", "data": { - "pbAdSlot": "pbslot_value" + "pbadslot": "pbslot_value" } }, "id": "test-imp-id", From dbd376594199cf0ad13c03b34dc4b95dc4da77f8 Mon Sep 17 00:00:00 2001 From: Piotr Jaworski Date: Wed, 18 Feb 2026 10:19:57 +0100 Subject: [PATCH 5/7] RTBHouse: use jsonutil for unmarshalling; improve error messaging --- adapters/rtbhouse/rtbhouse.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/adapters/rtbhouse/rtbhouse.go b/adapters/rtbhouse/rtbhouse.go index a7805d9f883..919b3987739 100644 --- a/adapters/rtbhouse/rtbhouse.go +++ b/adapters/rtbhouse/rtbhouse.go @@ -59,8 +59,8 @@ func (adapter *RTBHouseAdapter) MakeRequests( var publisherId string for _, imp := range openRTBRequest.Imp { - impExtMap := make(map[string]interface{}) - err := json.Unmarshal(imp.Ext, &impExtMap) + var impExtMap map[string]interface{} + err := jsonutil.Unmarshal(imp.Ext, &impExtMap) if err != nil { return nil, []error{&errortypes.BadInput{ Message: "Bidder extension not provided or can't be unmarshalled", @@ -219,7 +219,6 @@ func clearAuctionEnvironment(impExtMap map[string]interface{}) { } func getTagIDFromImpExt(impExtMap map[string]interface{}, impID string) string { - // imp.ext.gpid if gpid, ok := impExtMap["gpid"].(string); ok && gpid != "" { return gpid } @@ -233,7 +232,6 @@ func getTagIDFromImpExt(impExtMap map[string]interface{}, impID string) string { } } - // imp.ext.data.pbadslot if pbAdSlot, ok := dataMap["pbadslot"].(string); ok && pbAdSlot != "" { return pbAdSlot } @@ -252,11 +250,11 @@ func getImpressionExt(impExtMap map[string]interface{}) (*openrtb_ext.ExtImpRTBH bidderVal, ok := impExtMap["bidder"] if !ok { return nil, &errortypes.BadInput{ - Message: "Bidder extension not provided or can't be unmarshalled", + Message: "Bidder extension not provided", } } - bidderBytes, err := json.Marshal(bidderVal) + bidderBytes, err := jsonutil.Marshal(bidderVal) if err != nil { return nil, &errortypes.BadInput{ Message: "Bidder extension not provided or can't be unmarshalled", From b9ef063f67c726ae9e19f549829431ec943e430a Mon Sep 17 00:00:00 2001 From: Piotr Jaworski Date: Fri, 20 Feb 2026 17:18:24 +0100 Subject: [PATCH 6/7] RTBHouse: simplify un/marshalling steps --- adapters/rtbhouse/rtbhouse.go | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/adapters/rtbhouse/rtbhouse.go b/adapters/rtbhouse/rtbhouse.go index 919b3987739..882f4199d4e 100644 --- a/adapters/rtbhouse/rtbhouse.go +++ b/adapters/rtbhouse/rtbhouse.go @@ -67,7 +67,7 @@ func (adapter *RTBHouseAdapter) MakeRequests( }} } - rtbhouseExt, err := getImpressionExt(impExtMap) + rtbhouseExt, err := getImpressionExt(imp.Ext) if err != nil { return nil, []error{err} } @@ -238,31 +238,19 @@ func getTagIDFromImpExt(impExtMap map[string]interface{}, impID string) string { } // imp.ID as fallback - if impID != "" { - return impID - } - - return "" + return impID } -func getImpressionExt(impExtMap map[string]interface{}) (*openrtb_ext.ExtImpRTBHouse, error) { - // Check for bidder parameters in imp.ext.bidder - bidderVal, ok := impExtMap["bidder"] - if !ok { - return nil, &errortypes.BadInput{ - Message: "Bidder extension not provided", - } - } - - bidderBytes, err := jsonutil.Marshal(bidderVal) - if err != nil { +func getImpressionExt(impExt json.RawMessage) (*openrtb_ext.ExtImpRTBHouse, error) { + var bidderExt adapters.ExtImpBidder + if err := jsonutil.Unmarshal(impExt, &bidderExt); err != nil { return nil, &errortypes.BadInput{ Message: "Bidder extension not provided or can't be unmarshalled", } } var rtbhouseExt openrtb_ext.ExtImpRTBHouse - if err := jsonutil.Unmarshal(bidderBytes, &rtbhouseExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &rtbhouseExt); err != nil { return nil, &errortypes.BadInput{ Message: "Error while unmarshaling bidder extension", } From 9d59dea03ff30add933d63993a570c3c25b10efd Mon Sep 17 00:00:00 2001 From: Piotr Jaworski Date: Fri, 20 Feb 2026 17:25:17 +0100 Subject: [PATCH 7/7] RTBHouse: json -> jsonutil usage --- adapters/rtbhouse/rtbhouse.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adapters/rtbhouse/rtbhouse.go b/adapters/rtbhouse/rtbhouse.go index 882f4199d4e..3fe529c3aab 100644 --- a/adapters/rtbhouse/rtbhouse.go +++ b/adapters/rtbhouse/rtbhouse.go @@ -114,7 +114,7 @@ func (adapter *RTBHouseAdapter) MakeRequests( // remove PAAPI signals clearAuctionEnvironment(impExtMap) - newImpExt, err := json.Marshal(impExtMap) + newImpExt, err := jsonutil.Marshal(impExtMap) if err != nil { errs = append(errs, err) return nil, errs