From 6058d1e25e0cf7de4c0efb592b6aeeb31f6d1af3 Mon Sep 17 00:00:00 2001 From: Tal Avital Date: Thu, 12 Mar 2026 15:52:26 +0200 Subject: [PATCH 1/5] updated burl AUCTION_PRICE macro resolving --- adapters/taboola/taboola.go | 1 + .../taboola/taboolatest/exemplary/bannerResolveMacro.json | 6 ++++-- .../taboola/taboolatest/exemplary/nativeResolveMacro.json | 6 ++++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/adapters/taboola/taboola.go b/adapters/taboola/taboola.go index ec65a4b6777..0e277ada2d4 100644 --- a/adapters/taboola/taboola.go +++ b/adapters/taboola/taboola.go @@ -303,5 +303,6 @@ func resolveMacros(bid *openrtb2.Bid) { price := strconv.FormatFloat(bid.Price, 'f', -1, 64) bid.NURL = strings.Replace(bid.NURL, "${AUCTION_PRICE}", price, -1) bid.AdM = strings.Replace(bid.AdM, "${AUCTION_PRICE}", price, -1) + bid.BURL = strings.Replace(bid.BURL, "${AUCTION_PRICE}", price, -1) } } diff --git a/adapters/taboola/taboolatest/exemplary/bannerResolveMacro.json b/adapters/taboola/taboolatest/exemplary/bannerResolveMacro.json index b673096c0b5..f2bf2574c6c 100644 --- a/adapters/taboola/taboolatest/exemplary/bannerResolveMacro.json +++ b/adapters/taboola/taboolatest/exemplary/bannerResolveMacro.json @@ -114,7 +114,8 @@ "w": 300, "h": 250, "exp": 60, - "lurl": "https://lurl.domain.com/" + "lurl": "https://lurl.domain.com/", + "burl": "https://burl.domain.com/?wp=${AUCTION_PRICE}" } ], "seat": "1111" @@ -145,7 +146,8 @@ "w": 300, "h": 250, "exp": 60, - "lurl": "https://lurl.domain.com/" + "lurl": "https://lurl.domain.com/", + "burl": "https://burl.domain.com/?wp=2.1" }, "type": "banner" } diff --git a/adapters/taboola/taboolatest/exemplary/nativeResolveMacro.json b/adapters/taboola/taboolatest/exemplary/nativeResolveMacro.json index e30f123cc16..3a25b5688e8 100644 --- a/adapters/taboola/taboolatest/exemplary/nativeResolveMacro.json +++ b/adapters/taboola/taboolatest/exemplary/nativeResolveMacro.json @@ -86,7 +86,8 @@ "cid": "cid", "crid": "crid", "lurl": "https://lurl.domain.com/", - "nurl": "nurl.com&wp=${AUCTION_PRICE}" + "nurl": "nurl.com&wp=${AUCTION_PRICE}", + "burl": "https://burl.domain.com/?wp=${AUCTION_PRICE}" } ], "seat": "1111" @@ -116,7 +117,8 @@ "cid": "cid", "crid": "crid", "lurl": "https://lurl.domain.com/", - "nurl": "nurl.com&wp=2.1" + "nurl": "nurl.com&wp=2.1", + "burl": "https://burl.domain.com/?wp=2.1" }, "type": "native" } From 84f2ecdf771cc6da307eb451aa3036348064d523 Mon Sep 17 00:00:00 2001 From: Tal Avital Date: Thu, 12 Mar 2026 16:56:40 +0200 Subject: [PATCH 2/5] fix request.Ext overwrite by page type --- adapters/taboola/taboola.go | 20 +- .../exemplary/withPageTypeAndPrebidExt.json | 176 ++++++++++++++++++ adapters/taboola/utils.go | 6 +- 3 files changed, 190 insertions(+), 12 deletions(-) create mode 100644 adapters/taboola/taboolatest/exemplary/withPageTypeAndPrebidExt.json diff --git a/adapters/taboola/taboola.go b/adapters/taboola/taboola.go index 0e277ada2d4..9fbf36ecf6d 100644 --- a/adapters/taboola/taboola.go +++ b/adapters/taboola/taboola.go @@ -239,7 +239,7 @@ func createTaboolaRequests(request *openrtb2.BidRequest) (taboolaRequests []*ope } if taboolaExt.PageType != "" { - requestExt, requestExtErr := makeRequestExt(taboolaExt.PageType) + requestExt, requestExtErr := makeRequestExt(taboolaExt.PageType, modifiedRequest.Ext) if requestExtErr == nil { modifiedRequest.Ext = requestExt } else { @@ -253,17 +253,23 @@ func createTaboolaRequests(request *openrtb2.BidRequest) (taboolaRequests []*ope return taboolaRequests, errs } -func makeRequestExt(pageType string) (json.RawMessage, error) { - requestExt := &RequestExt{ - PageType: pageType, +func makeRequestExt(pageType string, existingExt json.RawMessage) (json.RawMessage, error) { + var extMap map[string]interface{} + if len(existingExt) > 0 { + if err := jsonutil.Unmarshal(existingExt, &extMap); err != nil { + extMap = make(map[string]interface{}) + } + } else { + extMap = make(map[string]interface{}) } - requestExtJson, err := json.Marshal(requestExt) + extMap["pageType"] = pageType + + requestExtJson, err := json.Marshal(extMap) if err != nil { - return nil, fmt.Errorf("could not marshal %s, err: %s", requestExt, err) + return nil, fmt.Errorf("could not marshal request ext, err: %s", err) } return requestExtJson, nil - } func getMediaType(impID string, imps []openrtb2.Imp) (openrtb_ext.BidType, error) { diff --git a/adapters/taboola/taboolatest/exemplary/withPageTypeAndPrebidExt.json b/adapters/taboola/taboolatest/exemplary/withPageTypeAndPrebidExt.json new file mode 100644 index 00000000000..4c4856e0475 --- /dev/null +++ b/adapters/taboola/taboolatest/exemplary/withPageTypeAndPrebidExt.json @@ -0,0 +1,176 @@ +{ + "mockBidRequest": { + "id": "request-id", + "imp": [ + { + "id": "impression-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ] + }, + "ext": { + "bidder": { + "publisherId": "publisher-id", + "tagid": "tag-id", + "pageType": "article" + } + } + } + ], + "site": { + "domain": "http://domain.com", + "page": "http://page-domain.com" + }, + "device": { + "ua": "Mozilla/5.0", + "h": 300, + "w": 300 + }, + "ext": { + "prebid": { + "channel": { + "name": "web", + "version": "1.0" + }, + "integration": "pbjs", + "server": { + "externalurl": "https://pbs.example.com", + "gvlid": 42, + "datacenter": "us-east-1" + }, + "sdk": { + "renderers": [ + { + "name": "test-renderer", + "version": "1.0.0" + } + ] + } + } + } + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://display.whatever.com/12/publisher-id", + "body": { + "id": "request-id", + "imp": [ + { + "id": "impression-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ] + }, + "tagid": "tag-id", + "ext": { + "bidder": { + "publisherId": "publisher-id", + "tagid": "tag-id", + "pageType": "article" + } + } + } + ], + "site": { + "id": "publisher-id", + "name": "publisher-id", + "domain": "http://domain.com", + "page": "http://page-domain.com", + "publisher": { + "id": "publisher-id" + } + }, + "device": { + "ua": "Mozilla/5.0", + "h": 300, + "w": 300 + }, + "ext": { + "pageType": "article", + "prebid": { + "channel": { + "name": "web", + "version": "1.0" + }, + "integration": "pbjs", + "server": { + "externalurl": "https://pbs.example.com", + "gvlid": 42, + "datacenter": "us-east-1" + }, + "sdk": { + "renderers": [ + { + "name": "test-renderer", + "version": "1.0.0" + } + ] + } + } + } + }, + "impIDs": ["impression-id"] + }, + "mockResponse": { + "status": 200, + "body": { + "id": "123", + "seatbid": [ + { + "bid": [ + { + "id": "request-id", + "impid": "impression-id", + "price": 2.1, + "adid": "1", + "adm": "", + "adomain": ["adomain.com"], + "cid": "cid", + "crid": "crid", + "w": 300, + "h": 250, + "exp": 60 + } + ], + "seat": "1111" + } + ], + "bidid": "123", + "cur": "USD" + } + } + } + ], + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "id": "request-id", + "impid": "impression-id", + "price": 2.1, + "adid": "1", + "adm": "", + "adomain": ["adomain.com"], + "cid": "cid", + "crid": "crid", + "w": 300, + "h": 250, + "exp": 60 + }, + "type": "banner" + } + ] + } + ] +} \ No newline at end of file diff --git a/adapters/taboola/utils.go b/adapters/taboola/utils.go index 2703ec69ad4..7c003daa78a 100644 --- a/adapters/taboola/utils.go +++ b/adapters/taboola/utils.go @@ -1,5 +1 @@ -package taboola - -type RequestExt struct { - PageType string `json:"pageType,omitempty"` -} +package taboola \ No newline at end of file From e8f8d0f193e226de0fa37a1277d3a66506ecf82a Mon Sep 17 00:00:00 2001 From: Tal Avital Date: Thu, 12 Mar 2026 17:10:29 +0200 Subject: [PATCH 3/5] update utils.go --- adapters/taboola/utils.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adapters/taboola/utils.go b/adapters/taboola/utils.go index 7c003daa78a..d0c0a629a8d 100644 --- a/adapters/taboola/utils.go +++ b/adapters/taboola/utils.go @@ -1 +1 @@ -package taboola \ No newline at end of file +package taboola From 43e3e0c56d462283eb59c69f2886bb3313b6fca3 Mon Sep 17 00:00:00 2001 From: Tal Avital Date: Sun, 19 Jul 2026 15:28:40 +0300 Subject: [PATCH 4/5] Taboola: propagate request ext unmarshal error and preserve ext fields --- adapters/taboola/taboola.go | 14 ++++++++------ adapters/taboola/taboola_test.go | 29 +++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/adapters/taboola/taboola.go b/adapters/taboola/taboola.go index 9fbf36ecf6d..f967daba953 100644 --- a/adapters/taboola/taboola.go +++ b/adapters/taboola/taboola.go @@ -254,20 +254,22 @@ func createTaboolaRequests(request *openrtb2.BidRequest) (taboolaRequests []*ope } func makeRequestExt(pageType string, existingExt json.RawMessage) (json.RawMessage, error) { - var extMap map[string]interface{} + extMap := make(map[string]json.RawMessage) if len(existingExt) > 0 { if err := jsonutil.Unmarshal(existingExt, &extMap); err != nil { - extMap = make(map[string]interface{}) + return nil, fmt.Errorf("could not unmarshal request ext: %s", err) } - } else { - extMap = make(map[string]interface{}) } - extMap["pageType"] = pageType + pageTypeJson, err := json.Marshal(pageType) + if err != nil { + return nil, fmt.Errorf("could not marshal pageType: %s", err) + } + extMap["pageType"] = pageTypeJson requestExtJson, err := json.Marshal(extMap) if err != nil { - return nil, fmt.Errorf("could not marshal request ext, err: %s", err) + return nil, fmt.Errorf("could not marshal request ext: %s", err) } return requestExtJson, nil } diff --git a/adapters/taboola/taboola_test.go b/adapters/taboola/taboola_test.go index 60004ef1ac8..6a5a6ff3169 100644 --- a/adapters/taboola/taboola_test.go +++ b/adapters/taboola/taboola_test.go @@ -1,6 +1,7 @@ package taboola import ( + "encoding/json" "testing" "github.com/prebid/prebid-server/v4/adapters/adapterstest" @@ -20,6 +21,34 @@ func TestJsonSamples(t *testing.T) { adapterstest.RunJSONBidderTest(t, "taboolatest", bidder) } +func TestMakeRequestExt(t *testing.T) { + t.Run("merges pageType into existing ext without dropping other fields", func(t *testing.T) { + existingExt := json.RawMessage(`{"prebid":{"integration":"pbjs"}}`) + + result, err := makeRequestExt("article", existingExt) + + assert.NoError(t, err) + assert.JSONEq(t, `{"prebid":{"integration":"pbjs"},"pageType":"article"}`, string(result)) + }) + + t.Run("sets pageType when existing ext is empty", func(t *testing.T) { + result, err := makeRequestExt("article", nil) + + assert.NoError(t, err) + assert.JSONEq(t, `{"pageType":"article"}`, string(result)) + }) + + t.Run("returns error when existing ext is invalid JSON", func(t *testing.T) { + invalidExt := json.RawMessage(`not-a-json-object`) + + result, err := makeRequestExt("article", invalidExt) + + assert.Error(t, err) + assert.Contains(t, err.Error(), "could not unmarshal request ext") + assert.Nil(t, result) + }) +} + func TestEmptyExternalUrl(t *testing.T) { bidder, buildErr := Builder(openrtb_ext.BidderTaboola, config.Adapter{ Endpoint: "http://whatever.com"}, config.Server{}) From bceff2cfbc35612cb848d3a10a84a5959ff97a9c Mon Sep 17 00:00:00 2001 From: Tal Avital Date: Mon, 27 Jul 2026 11:51:14 +0300 Subject: [PATCH 5/5] Taboola: use jsonutil for marshaling and remove empty utils.go --- adapters/taboola/taboola.go | 4 ++-- adapters/taboola/utils.go | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) delete mode 100644 adapters/taboola/utils.go diff --git a/adapters/taboola/taboola.go b/adapters/taboola/taboola.go index f967daba953..65b757bf3b1 100644 --- a/adapters/taboola/taboola.go +++ b/adapters/taboola/taboola.go @@ -261,13 +261,13 @@ func makeRequestExt(pageType string, existingExt json.RawMessage) (json.RawMessa } } - pageTypeJson, err := json.Marshal(pageType) + pageTypeJson, err := jsonutil.Marshal(pageType) if err != nil { return nil, fmt.Errorf("could not marshal pageType: %s", err) } extMap["pageType"] = pageTypeJson - requestExtJson, err := json.Marshal(extMap) + requestExtJson, err := jsonutil.Marshal(extMap) if err != nil { return nil, fmt.Errorf("could not marshal request ext: %s", err) } diff --git a/adapters/taboola/utils.go b/adapters/taboola/utils.go deleted file mode 100644 index d0c0a629a8d..00000000000 --- a/adapters/taboola/utils.go +++ /dev/null @@ -1 +0,0 @@ -package taboola