Stats: Tags and Categories details crashes when two expanded groups share a tag

Abierto Apto para principiantes
#26,458 1 comentario 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
76/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
ios, swift
Área
mobile

Línea de trabajo

Empieza por StatsDataHelper.swift, especialmente por childRowsForItems y expandableDataRowsFor, y luego inspecciona la igualdad de DetailExpandableChildRow y la corrección del issue #26415. Reproduce el problema con dos grupos de etiquetas que compartan una etiqueta y al menos siete entradas; después, expande ambos grupos en la tarjeta clásica Tags and Categories. El trabajo estará terminado cuando ambos grupos se expandan sin provocar un cierre inesperado y las secciones expandibles relacionadas sigan funcionando correctamente.

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

Descripción

[Type] Crash Stats

The app crashes when you expand two groups in the classic Insights → Tags and Categories → View more screen that share a tag. We reproduced it on an iOS 27.2 simulator using stats data served from a local proxy. None of the crash reports Sentry still keeps for this crash signature (JETPACK-IOS-1ASW) come from this screen, so we don't know how many users hit it.

Who hits it

Anyone whose top tags include two groups with a tag in common. The Stats API groups tags that appear together on a post, so a site with posts tagged "news, tech" and "news, sport" shows two groups that both contain "news". Expanding both crashes the app.

Why

The expanded tag rows only hold the tag's name, an empty count and its URL. Nothing ties a row to the group it's in, so the two "news" rows are equal, and the diffable table rejects them as duplicate items (NSInternalInconsistencyException: "supplied item identifiers are not unique"). The rows are built by childRowsForItems:

https://github.com/wordpress-mobile/WordPress-iOS/blob/5a363729ba2016c48ecdbe8ca2695db642d09f52/WordPress/Classes/ViewRelated/Stats/Helpers/StatsDataHelper.swift#L90-L98

#26415 fixes the same crash for Post Stats month rows, which is the case behind all retained Sentry reports, but it does not cover tags.

Fix

  • Make each expanded child row include its parent row's identity (for example the parent's name and statSection) in DetailExpandableChildRow equality, set in expandableDataRowsFor.
  • That one change covers every expandable section built there: tags, months, and possibly Authors (a co-authored post under two authors) and repeated Clicks or Referrers entries. Those last cases have not been reproduced.

How to reproduce

  1. Use a site whose stats return two tag groups sharing a tag (for example "news, tech" and "news, sport") and at least seven entries, so the card shows View more.
  2. With New Stats turned off, open Insights, add the Tags and Categories card if needed, and tap View more.
  3. Expand "news, tech", then "news, sport". The app crashes.
Crash log from the simulator (Jetpack Debug, built from #26415)
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Fatal: supplied item identifiers are not unique. Duplicate identifiers: {(
    WordPress.AnyHashableImmuTableRow(immuTableRow: WordPress.DetailExpandableChildRow(rowData: WordPress.StatsTotalRowData(id: nil, name: "news", data: "", ..., showDisclosure: true, disclosureURL: Optional(https://jkmassel.wordpress.com/tag/news/), multiline: true, childRows: Optional([]), statSection: nil, isReferrerSpam: false, month: nil), ..., hideIndentedSeparator: true, hideFullSeparator: true, ...))
)}'

The tags response the proxy served:

{"tags": [
  {"views": 20, "tags": [{"name": "news", "type": "tag"}, {"name": "tech", "type": "tag"}]},
  {"views": 10, "tags": [{"name": "news", "type": "tag"}, {"name": "sport", "type": "tag"}]},
  {"views": 9, "tags": [{"name": "filler0", "type": "tag"}]},
  "... five more single-tag entries"
]}
Lenguaje dominante
Swift
Estrellas
3.9k
Forks
1.2k
Merge medio
1 d 21 h
PR fusionados (30 d)
126

Preparar el entorno

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 wordpress-mobile/WordPress-iOS

Todos los issues de wordpress-mobile/WordPress-iOS

Issues similares

Más issues de Swift

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.