Report Core Data migration failures to Sentry

Aperta
#26,285 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
48/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
ios, swift

Direzione di ricerca

Read Modules/Sources/WordPressData/Swift/ContextManager.swift and CoreDataHelper.swift:284, then trace how the app connects error reporting to Sentry without relying on the app delegate. Cover failed step-by-step migration, store-open failure, and restoreStoreCopy errors, including the case where fallback migration succeeds. Done means each failure is reported and the unused SentryStartupEvent is removed if it still has no callers.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

[Type] Tech Debt Core Data

Core Data migration failures are only written to the app log. Sentry never hears about them, so we can't tell how often they happen.

Split out of #13014.

What happens

In ContextManager.createPersistentContainer (Modules/Sources/WordPressData/Swift/ContextManager.swift):

  • A failed step-by-step migration is logged with DDLogError("Unable to migrate store") and nothing else. Core Data's automatic migration then runs, and if it succeeds nobody is told.
  • A store that can't be opened at all is backed up and the app crashes with an NSException. The Sentry event that used to explain why is commented out too.
  • The Sentry calls were commented out in #24378 (c062a59ae4) with // FIXME: Import the Sentry stuff, too — But it accesses the app delegate!. SentryStartupEvent now has no callers.
  • CoreDataHelper.restoreStoreCopy (the WordPress → Jetpack data import) runs the migrator with try? (CoreDataHelper.swift:284), so failures there aren't even logged.

Why it matters

Today a failed step loses nothing, because every migration step is inferred (#24208 removed all custom mappings). But if someone adds a custom mapping, a failed step would silently skip it, which is the data loss described in #13014. Without reporting, we wouldn't know.

Suggested fix

  1. Give ContextManager a way to report errors that WordPressData can reach without the app delegate. For example, an error handler the app sets at launch that forwards to CrashLogging, or a swift-log error the app already sends to Sentry.
  2. Report a failed step-by-step migration even when the fallback succeeds, the store-open failure before the crash, and the try? in restoreStoreCopy.
  3. Delete SentryStartupEvent if it stays unused.
Lingua principale
Swift
Stelle
3.9k
Fork
1.2k
Merge medio
1g 23h
PR unite (30g)
136

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di wordpress-mobile/WordPress-iOS

Tutte le issue di wordpress-mobile/WordPress-iOS

Issue simili

Altre issue su Swift

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.