Page MenuHomePhabricator

Malformed wiki field in mobile app event logs
Closed, ResolvedPublic

Description

For example:

SELECT
  id, uuid, timestamp, userAgent, wiki
FROM MobileWikiAppShareAFact_12588711
WHERE timestamp >= '20180201'
  AND wiki RLIKE '^WikipediaApp'
iduuidtimestampuserAgentwiki
4624555058a8e87003295bf393bf432cc49e9d7520180201000906{"wmf_app_version": "2.4.184-beta-2016-12-14", "os_minor": "1", "os_major": "4", "is_bot": false, "device_family": "Generic Smartphone", "os_family": "Android", "browser_minor": "1", "is_mediawiki": false, "browser_major": "4", "browser_family": "Android"}WikipediaApp/2.4.184-beta-2016-12-14 (Android 4.1.2; Phone) Google Play Beta Channel
46246058339e6284846c5f8dbc9bf87b714131f420180201001400{"wmf_app_version": "2.4.184-r-2016-12-14", "os_minor": "4", "os_major": "4", "is_bot": false, "device_family": "Generic Smartphone", "os_family": "Android", "browser_minor": "4", "is_mediawiki": false, "browser_major": "4", "browser_family": "Android"}WikipediaApp/2.4.184-r-2016-12-14 (Android 4.4.4; Phone) Google Play

At first I thought it may be caused by right-to-left languages but a quick look at the events showed the problem is language-independent.

How widespread the problem is (at least across MobileWikiApp* schemas), restricted to 2018 data:

affectedschemaeventsproportion
MobileWikiAppAppearanceSettings_103754628230.11%
MobileWikiAppArticleSuggestions_1530221214670.18%
MobileWikiAppCreateAccount_91353919280.85%
MobileWikiAppDailyStats_1263738514360.03%
MobileWikiAppEdit_900312533111.68%
MobileWikiAppFeedConfigure_1749059500.00%
MobileWikiAppFeed_15734713384828.20%
MobileWikiAppFeed_1643246700.00%
MobileWikiAppFindInPage_1458677410000.20%
MobileWikiAppInstallReferrer_1260190500.00%
MobileWikiAppIntents_1523738427410.31%
MobileWikiAppLangSelect_125887332770.89%
MobileWikiAppLinkPreview_15730939588680.33%
MobileWikiAppLogin_913539036790.95%
MobileWikiAppMediaGallery_1258870116260.42%
MobileWikiAppNavMenu_1273221100.00%
MobileWikiAppOfflineLibrary_1764922100.00%
MobileWikiAppOnThisDay_1749076700.00%
MobileWikiAppOnboarding_912346600.00%
MobileWikiAppPageScroll_14591606412950.27%
MobileWikiAppProtectedEditAttempt_86824971080.12%
MobileWikiAppRandomizer_1749046300.00%
MobileWikiAppReadingLists_15520526159640.36%
MobileWikiAppSavedPages_1037548000.00%
MobileWikiAppSearch_1572932193090.32%
MobileWikiAppSessions_15522505592156.34%
MobileWikiAppShareAFact_12588711136200.12%
MobileWikiAppStuffHappens_895546800.00%
MobileWikiAppTabs_1245365134380.24%
MobileWikiAppToCInteraction_1458531915400.21%
MobileWikiAppWidgets_1131287000.00%
MobileWikiAppWiktionaryPopup_15158116570.47%

I have not checked the other schemas.

Here's the R code I used to figure out these stats:

library(tidyverse)

mobile_schemas <- wmf::mysql_read("SHOW TABLES;", "log") %>%
  filter(grepl("^MobileWikiApp[A-Za-z]+_[0-9]+$", Tables_in_log))

query <- "SELECT
  wiki RLIKE '^WikipediaApp' AS malformed,
  COUNT(*) AS events
FROM {schema}
WHERE timestamp >= '20180101'
GROUP BY malformed;"
malformations <- lapply(mobile_schemas$Tables_in_log, function(schema) {
  result <- try(wmf::mysql_read(glue::glue(query), "log"))
  if (inherits(result, "try-error")) return(NULL)
  else {
    if (all(c(0, 1) %in% result$malformed)) {
      counts <- tidyr::spread(result, malformed, events)
      output <- c(
        events = counts$`1`,
        proportion = counts$`1` / (counts$`0` + counts$`1`)
      )
      return(output)
    } else {
      return(data.frame(
        events = if_else(result$malformed[1] == 0, 0, result$events[1]),
        proportion = if_else(result$malformed[1] == 0, 0, 1.0)
      ))
    }
  }
}) %>% set_names(mobile_schemas$Tables_in_log) %>% do.call(rbind, .)

malformations$schema <- row.names(malformations)
malformations %>%
  mutate(
    affected = if_else(events > 0, "★", ""),
    proportion = sprintf("%.2f%%", proportion * 100)
  ) %>%
  select(affected, schema, events, proportion) %>%
  knitr::kable(format = "markdown", align = c("c", "l", "r", "r"))

Event Timeline

mpopov triaged this task as Unbreak Now! priority.

Yes indeed, there were some old versions of the app (from around Dec 2016) that were erroneously populating the wiki field with the app version, but is this actually happening with any recent versions of the app?

mpopov claimed this task.

Yes indeed, there were some old versions of the app (from around Dec 2016) that were erroneously populating the wiki field with the app version, but is this actually happening with any recent versions of the app?

Oh, yup! The latest version with the bug is 2.4.184

SELECT DISTINCT RIGHT(LEFT(userAgent, 30), 9) AS app_version
FROM MobileWikiAppLinkPreview_15730939
WHERE timestamp >= '20180201'
  AND wiki RLIKE '^WikipediaApp'
ORDER BY app_version DESC;

Thank you for clarifying!