Skip to content

[Crashlytics] Refactor non-fatal error logging to use FIRCLSNonFatalError model - #16139

Merged
mghaznav merged 7 commits into
mainfrom
ali/crashlytics-nfa-refactor
May 6, 2026
Merged

mghaznav merged 7 commits into
mainfrom
ali/crashlytics-nfa-refactor

Conversation

@mghaznav

@mghaznav mghaznav commented Apr 29, 2026 •

Copy link
Copy Markdown
Contributor

Description

Historically, non-fatal errors in Crashlytics were simple enough that passing a few parameters to a helper function sufficed. However, with the added complexity of Crashlytics' asynchronous initialization, we now need to explicitly separate the data collection logic from the disk recording logic to ensure we preserve the correct execution context.

This PR addresses that complexity by introducing a dedicated FIRCLSNonFatalError class. This model records the state of the error at initialization and provides another method to write the error to disk, effectively seperating the 2.

Related Issues & PRs

Changes Made

  • Created the FIRCLSNonFatalError class in Crashlytics/Models/ to act as an immutable state snapshot.
  • Updated recordError:userInfo: to initialize this model before entering the async queue, guaranteeing the origin stack trace is preserved regardless of how long initialization takes.

Testing & Verification

  • Real Device Testing: Deployed and verified on a physical iOS device to ensure non-fatal payloads are generated and uploaded correctly.
  • Unit Tests: All existing and newly affected unit tests are passing successfully.
  • Code Quality: Passed the internal linting and formatting checks (./scripts/check.sh).

#no-changelog

@mghaznav
mghaznav requested a review from tejasd April 29, 2026 18:26
@mghaznav mghaznav self-assigned this Apr 29, 2026
@gemini-code-assist

Copy link
Copy Markdown
Contributor
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

@mghaznav

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request refactors non-fatal error recording by introducing the FIRCLSNonFatalError class to capture execution context at initialization. Feedback recommends restoring an early return for nil errors in FIRCrashlytics.m to prevent unnecessary processing and explicitly copying properties in the FIRCLSNonFatalError initializer to ensure data integrity and immutability.

Comment thread Crashlytics/Crashlytics/FIRCrashlytics.m
Comment thread Crashlytics/Crashlytics/Models/FIRCLSNonFatalError.m Outdated
@mghaznav
mghaznav removed the request for review from tejasd April 29, 2026 18:31
mghaznav and others added 2 commits April 29, 2026 14:34
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@mghaznav
mghaznav requested a review from tejasd April 29, 2026 18:48
@tejasd
tejasd requested a review from ncooke3 April 29, 2026 21:53
Comment thread Crashlytics/Crashlytics/FIRCrashlytics.m
Comment thread Crashlytics/CHANGELOG.md Outdated
Comment thread Crashlytics/Crashlytics/Models/FIRCLSNonFatalError.h
@danger-firebase-ios

Copy link
Copy Markdown
1 Warning
⚠️ Did you forget to add a changelog entry? (Add #no-changelog to the PR description to silence this warning.)

Generated by 🚫 Danger

@mghaznav
mghaznav merged commit 30c4eff into main May 6, 2026
53 checks passed
@mghaznav
mghaznav deleted the ali/crashlytics-nfa-refactor branch May 6, 2026 15:04
leojaygoogle pushed a commit that referenced this pull request Jun 29, 2026
…Error` model (#16139)

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants