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

Aberta
#4,716 0 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 2 dias

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
3/5
Tempo estimado
1-2 dias
Facilidade para iniciantes
71/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
java
Domínio
backend

Direção de pesquisa

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.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

🤖 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

Linguagem predominante
Java
Estrelas
108
Forks
258
Merge médio
3d 20h
PRs com merge (30d)
12

Preparar o ambiente

Abrir no Codespaces

Inicia o contêiner de desenvolvimento do projeto no navegador, com a sua própria conta do GitHub.

  • Inclui um Dockerfile ou arquivo Docker Compose
  • Tem um modelo de pull request
  • Sem guia de contribuição

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de prebid/prebid-server-java

Todas as issues de prebid/prebid-server-java

Issues semelhantes

Mais issues de Java

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.