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

オープン
#4,716 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

まだ誰も着手していません。

評価

難易度
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時間
マージ済み PR(30日)
12

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

  • Dockerfile または Docker Compose ファイルあり
  • プルリクエストのテンプレートあり
  • コントリビューションガイドなし

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

prebid/prebid-server-java のほかの issue

prebid/prebid-server-java の issue をすべて見る

似ている issue

Java の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。