Skip to content

Expand FcmLifecycleCallbacks try/catch to cover analytics dispatch#8051

Open
jrodiz wants to merge 1 commit intofirebase:mainfrom
jrodiz:hotfix/jrc--8049.Prevent.crash.on.malformed.extras
Open

Expand FcmLifecycleCallbacks try/catch to cover analytics dispatch#8051
jrodiz wants to merge 1 commit intofirebase:mainfrom
jrodiz:hotfix/jrc--8049.Prevent.crash.on.malformed.extras

Conversation

@jrodiz
Copy link
Copy Markdown
Collaborator

@jrodiz jrodiz commented Apr 21, 2026

Move MessagingAnalytics.shouldUploadScionMetrics + logNotificationOpen calls inside the existing try block so that any RuntimeException from the extras Bundle (including malformed Serializable extras delivered to an exported activity) cannot propagate out of Application.dispatchActivityCreated.

 private void logNotificationOpen(Intent startingIntent) {
   Bundle analyticsData = null;
   try {
     Bundle extras = startingIntent.getExtras();
     if (extras != null) { … }
+    if (MessagingAnalytics.shouldUploadScionMetrics(analyticsData)) {
+      MessagingAnalytics.logNotificationOpen(analyticsData);
+    }
   } catch (RuntimeException e) {
     Log.w(TAG, "Failed trying to get analytics data from Intent extras.", e);
   }
-  if (MessagingAnalytics.shouldUploadScionMetrics(analyticsData)) {
-    MessagingAnalytics.logNotificationOpen(analyticsData);
-  }
 }

Fixes #8049.

Move MessagingAnalytics.shouldUploadScionMetrics + logNotificationOpen calls
inside the existing try block so that any RuntimeException from the extras
Bundle (including malformed Serializable extras delivered to an exported
activity) cannot propagate out of Application.dispatchActivityCreated.

Fixes firebase#8049.
@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.

@jrodiz
Copy link
Copy Markdown
Collaborator Author

jrodiz commented Apr 21, 2026

/gemini review

}
if (MessagingAnalytics.shouldUploadScionMetrics(analyticsData)) {
MessagingAnalytics.logNotificationOpen(analyticsData);
}
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Maybe a separate try/catch in case previous scenario fails?

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

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 prevents potential application crashes in FcmLifecycleCallbacks by moving the analytics logging logic inside a try-catch block. This ensures that malformed Intent extras do not cause unhandled exceptions during notification open events. I have no feedback to provide.

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.

[firebase_messaging]: App crashes when exported activity receives malformed Intent extras via FcmLifecycleCallbacks

1 participant