Skip to content

MOBILE-187: Remove AppGroup misconfiguration crash#725

Merged
justSmK merged 16 commits into
developfrom
MOBILE-187
Jun 26, 2026
Merged

MOBILE-187: Remove AppGroup misconfiguration crash#725
justSmK merged 16 commits into
developfrom
MOBILE-187

Conversation

@justSmK

@justSmK justSmK commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

Issue

The SDK no longer crashes the host app when the App Group container is unavailable (missing/misconfigured/unprovisioned capability): every fatalError/assertionFailure on that path (core fetcher, DI persistence factory, logger store, Example) now degrades to local storage and surfaces a .fault log instead. Adds a read-only diagnostic that logs when it detects a fallback→App-Group re-registration (install state in both stores), plus regression tests for all the fallback branches. Verified end-to-end on a real iPhone 12 — no crash through the full broken→fixed lifecycle.

@github-actions

github-actions Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor
TestsPassed ✅SkippedFailedTime ⏱
Unit tests report1136 ran1136 ✅1m 35s 203ms

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses MOBILE-187 / issue #705 by removing crash paths caused by App Group misconfiguration/unavailability and ensuring both the core SDK and logger degrade to local storage instead of trapping. It also adds regression tests covering the previously untested fallback behavior.

Changes:

  • Replace fatalError-based App Group resolution with non-trapping fallbacks (core SDK returns ""; logger returns nil) and add fault logging.
  • Make logger store URL resolution throw (FileManager.storeURL) instead of crashing, and propagate via LoggerDatabaseLoader.
  • Add regression tests for App Group unavailability and for the storage-transition reporter behavior.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
MindboxTests/DI/AppGroupUnavailableTests.swift New regression tests covering App Group unavailability fallbacks and transition reporter behavior.
MindboxLoggerTests/MBLoggerUtilitiesFetcherTests.swift New test ensuring logger utilities fetcher never traps.
MindboxLoggerTests/FileManagerStoreURLTests.swift New tests for throwing storeURL + loader fallback to local caches.
MindboxLogger/Shared/LoggerRepository/LoggerDatabaseLoader.swift Update to call throwing FileManager.storeURL with try.
MindboxLogger/Shared/Extensions/MBLoggerUtilitiesFetcher.swift Remove trap; return nil when App Group container can’t be resolved.
MindboxLogger/Shared/Extensions/FileManager+Extensions.swift Replace fatalError with a typed throwing error for App Group container resolution.
Mindbox/Utilities/UtilitiesFetcher/MBUtilitiesFetcher.swift Remove trap; log fault and return "" when App Group is unavailable.
Mindbox/PersistenceStorage/MBPersistenceStorage.swift Add install-state probing helpers + AppGroupStorageTransitionReporter.
Mindbox/DI/Injections/InjectReplaceable.swift Make persistence storage DI fallback to .standard on empty App Group + log on suite init failure.
Mindbox/CoreController/CoreController.swift Invoke transition reporter during initialization.
Mindbox.xcodeproj/project.pbxproj Wire new test files into test targets.
Example/Example/NotificationCenter/SwiftDataManager.swift Avoid crashing the example app when App Group container URL can’t be resolved.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread MindboxTests/DI/AppGroupUnavailableTests.swift
Comment thread MindboxLogger/Shared/Extensions/FileManager+Extensions.swift
Comment thread Mindbox/Utilities/UtilitiesFetcher/MBUtilitiesFetcher.swift
justSmK added 14 commits June 26, 2026 14:09
Surfaces the silent re-registration when a broken App Group is later fixed (issue #705 follow-up).
The fallback test overwrote the global buildTestContainer without restoring it, which could leak its minimal builder into later .test-mode suites.
Drop a duplicated/speculative comment (point to AppGroupStorageTransitionReporter), tighten the fetcher docs, and use === for the reporter's store-identity check.
reportIfNeeded() runs before re-registration, so the recovery launch itself doesn't fire; the earliest is the next cold start.
Restore the static MBPersistenceStorage.defaults the fallback test mutates, and add a regression test that a real App Group suite does not read through to .standard (the invariant the transition reporter relies on).
…lback

The read-through test verifies generic UserDefaults suite isolation (the runner has no App Group entitlement), not entitlement-specific behavior — rename + reword accordingly. Parameterize the events-store test over [nil, ""] so both defaultDirectoryURL() fallback branches are pinned.
justSmK added 2 commits June 26, 2026 16:21
It's an internal forensic record that a fallback->recovery happened, not an integrator-actionable error. It stays persisted to the log store regardless of level (retrievable from exports), so this just stops it spamming the console on every cold start.
Moved after primaryInitialization so the suite marker is already written: it now fires on the recovery launch itself instead of one cold start later. Read-only and gated on the same install marker, so no false positive on clean installs or failed re-registration.
@justSmK justSmK merged commit 890d4dd into develop Jun 26, 2026
7 checks passed
@justSmK justSmK deleted the MOBILE-187 branch June 26, 2026 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants