Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[firebase_analytics]: logPurchase crashes when any of the values inside parameters is null #12790

Closed
1 task done
jorgecoca opened this issue May 16, 2024 · 2 comments
Closed
1 task done
Labels
blocked: customer-response Waiting for customer response, e.g. more information was requested. Needs Attention This issue needs maintainer attention. platform: all Issues / PRs which are for all platforms. plugin: analytics resolution: duplicate This issue or pull request already exists type: bug Something isn't working

Comments

@jorgecoca
Copy link

Is there an existing issue for this?

  • I have searched the existing issues.

Which plugins are affected?

Analytics

Which platforms are affected?

Android, iOS, macOS, Web, Windows

Description

Firebase Analytics version: 10.10.4

logPurchase accepts a parameters input with the signature Map<String, Object?>?, so a call like this should work:

firebaseAnalytics.logPurchase(value: 123, parameters: { 'hello': null });

However, this code crashes due to an internal call to a method named _assertParameterTypesAreCorrect:

void _assertParameterTypesAreCorrect(Map<String, Object?>? parameters) =>
    parameters?.forEach((key, value) {
      assert(
        value is String || value is num,
        "'string' OR 'number' must be set as the value of the parameter: $key. $value found instead",
      );
    });

where the assert does not allow value to be null, creating the crash.

Reproducing the issue

Call logPurchase with parameters having a null value.

firebaseAnalytics.logPurchase(value: 123, parameters: { 'hello': null });

Firebase Core version

2.31.0

Flutter Version

3.19.6

Relevant Log Output

[log] #0      _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:51:61)
      #1      _AssertionError._throwNew (dart:core-patch/errors_patch.dart:40:5)
      #2      _assertParameterTypesAreCorrect.<anonymous closure> (package:firebase_analytics/src/firebase_analytics.dart:1501:9)
      #3      _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:633:13)
      #4      _assertParameterTypesAreCorrect (package:firebase_analytics/src/firebase_analytics.dart:1499:17)
      #5      FirebaseAnalytics.logPurchase (package:firebase_analytics/src/firebase_analytics.dart:885:5)
      #6      FirebaseAnalyticsRepository.purchase (package:firebase_analytics_repository/src/firebase_analytics_repository.dart:100:28)


### Flutter dependencies

<!--- Look below for instructions on how to share your Flutter Dependencies. --->

<details>
<summary>Expand <code>Flutter dependencies</code> snippet</summary>
<br>

```yaml

Replace this line with the contents of your `flutter pub deps -- --style=compact`.

Additional context and comments

No response

@jorgecoca jorgecoca added Needs Attention This issue needs maintainer attention. type: bug Something isn't working labels May 16, 2024
@russellwheatley
Copy link
Member

russellwheatley commented May 17, 2024

@jorgecoca - null values are not allowed which is why we have that assertion. We do have a PR for fixing incorrect types but it is a breaking change, and we are waiting until the time when we cut a breaking change release: #12427

@russellwheatley russellwheatley added blocked: customer-response Waiting for customer response, e.g. more information was requested. plugin: analytics Needs Attention This issue needs maintainer attention. platform: all Issues / PRs which are for all platforms. and removed Needs Attention This issue needs maintainer attention. labels May 17, 2024
@jorgecoca
Copy link
Author

Understood! I think in this case it makes sense to close the issue and the associated PR, since the compiler will catch those issues in the next release.

Thank you!

@TarekkMA TarekkMA added the resolution: duplicate This issue or pull request already exists label May 20, 2024
@firebase firebase locked and limited conversation to collaborators Jun 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
blocked: customer-response Waiting for customer response, e.g. more information was requested. Needs Attention This issue needs maintainer attention. platform: all Issues / PRs which are for all platforms. plugin: analytics resolution: duplicate This issue or pull request already exists type: bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants