Report Core Data migration failures to Sentry

オープン
#26,285 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
48/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
ios, swift

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

[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.
主要言語
Swift
スター
3.9k
フォーク
1.2k
平均マージ
1日 23時間
マージ済み PR(30日)
136

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

wordpress-mobile/WordPress-iOS のほかの issue

wordpress-mobile/WordPress-iOS の issue をすべて見る

似ている issue

Swift の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。