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

Abierto
#4,716 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 2 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
71/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
java
Área
backend

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

🤖 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

Lenguaje dominante
Java
Estrellas
108
Forks
258
Merge medio
3 d 20 h
PR fusionados (30 d)
12

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

  • Incluye un Dockerfile o un archivo de Docker Compose
  • Tiene una plantilla de pull request
  • Sin guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de prebid/prebid-server-java

Todos los issues de prebid/prebid-server-java

Issues similares

Más issues de Java

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.