Analytics: updateEventIfRequired mutates the shared ext.prebid.analytics node

未關閉
#4,716 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 2 天內回覆

還沒有人認領這個 Issue。

評估

難度
3/5
預估耗時
1-2 天
新手友好度
71/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
java
領域
backend

研究方向

Read AnalyticsReporterDelegator.java, especially updateAuctionContext at the linked lines, and trace how prepareAnalytics handles reporters without an analytics entry. Reproduce the AMP or video case with two reporters and account module config, then check that each reporter receives its own analytics node and the original request remains unchanged.

由索引模型根據 Issue 內容生成。

描述

🤖 This issue was written by an AI agent (Claude Code) on behalf of @patmmccann.

What happens

updateEventIfRequired → updateAuctionContext merges the account's analytics.modules.<reporter> config into ext.prebid.analytics.<reporter> for each reporter, but it writes into the request's existing JsonNode objects instead of copies:

https://github.com/prebid/prebid-server-java/blob/9ac33456c4d57336fdb2514fa15b792fdfb3d20d/src/main/java/org/prebid/server/analytics/reporter/AnalyticsReporterDelegator.java#L433-L446

  • adapterNode is the live analyticsNode.get(adapterName) when it exists, and adapterNode.set(...) adds the account fields to it.
  • ((ObjectNode) analyticsNode).set(adapterName, adapterNode) changes the shared ext.prebid.analytics object.

The new BidRequest/AuctionContext built afterwards still points to the same, now changed, node.

Which node is shared:

  • AMP and video events: always the original request's node, because they aren't trimmed per reporter (see https://github.com/prebid/prebid-server-java/issues/4715).
  • Auction events: the original node for any reporter that has no entry in ext.prebid.analytics, because prepareAnalytics returns null and the original ext is kept (L324-L350). It is also the original node for logAnalytics, which is exempt from trimming.

Reporters run one after another through vertx.runOnContext. So when a reporter that shares the node runs after another reporter's config was merged into it, it sees the earlier reporter's account-level module config under the earlier reporter's key.

Why it matters

Account-level analytics module config (e.g. per-publisher keys or scope IDs for a reporter) could end up visible to other reporters. Which reporters see it depends on reporter order. Changing the request in place from inside the analytics path is also fragile if anything else reads the request afterwards.

To reproduce

Two reporters enabled, e.g. pubstack and greenbids. Account config:

{ "analytics": { "modules": { "pubstack": { "key1": "a" }, "greenbids": { "key2": "b" } } } }

An AMP (via stored request) or video request with "ext": {"prebid": {"analytics": {"pubstack": {}, "greenbids": {}}}}: the reporter that runs second sees the other reporter's merged account fields in ext.prebid.analytics.

Expected behaviour

Each reporter gets its own copy of ext.prebid.analytics (ideally trimmed to its own entry), and the request object isn't changed.

Suggested fix

Work on analyticsNode.deepCopy() (and a copy of the adapter node) in updateAuctionContext, and build the new ExtRequestPrebid from that copy.

References

🤖 Generated with Claude Code

主要語言
Java
星號
108
分支
258
平均合併
3 天 20 小時
30 天內合併 PR
12

環境準備

在 Codespaces 中開啟

在瀏覽器裡用你自己的 GitHub 帳號啟動這個專案的開發容器。

  • 提供 Dockerfile 或 Docker Compose 檔案
  • 有 Pull Request 範本
  • 沒有貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

prebid/prebid-server-java 的其他 Issue

查看 prebid/prebid-server-java 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。