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

setExtra while configuring scope throw ClassCastException #2098

Closed
clementperineau opened this issue Jun 12, 2024 · 2 comments · Fixed by #2159
Closed

setExtra while configuring scope throw ClassCastException #2098

clementperineau opened this issue Jun 12, 2024 · 2 comments · Fixed by #2159
Assignees

Comments

@clementperineau
Copy link

Platform

Dart

Obfuscation

Disabled

Debug Info

Disabled

Doctor

Dart 3.3.3

Version

8.2.0

Steps to Reproduce

Use setExtra while configuring scope

Sentry.configureScope(
  (scope) {
    scope.setExtra('extra_data', 'data');
  },
);

Expected Result

Add extra data to scope.

Actual Result

Throw platform error when calling native code using platform channel.

I guess setExtra should be deprecated. But the method does not have deprecated flag.

PlatformException (PlatformException(error, java.lang.Integer cannot be cast to java.lang.String, null, java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
	at io.sentry.flutter.SentryFlutterPlugin.onMethodCall(SentryFlutterPlugin.kt:70)
	at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:267)
	at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:292)
	at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:319)
	at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(D8$$SyntheticClass:0)
	at android.os.Handler.handleCallback(Handler.java:942)
	at android.os.Handler.dispatchMessage(Handler.java:99)
	at android.os.Looper.loopOnce(Looper.java:201)
	at android.os.Looper.loop(Looper.java:288)
	at android.app.ActivityThread.main(ActivityThread.java:7898)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
))

Are you willing to submit a PR?

None

@buenaflor
Copy link
Contributor

buenaflor commented Jun 14, 2024

Hi thx for the issue

it seems to be an oversight since the setExtra function in Scope should've been deprecated in v8

@buenaflor
Copy link
Contributor

In general we recommend using contexts instead of extra, see here

@buenaflor buenaflor moved this from Needs Discussion to Backlog in Mobile & Cross Platform SDK Jun 20, 2024
@buenaflor buenaflor moved this from Backlog to Todo in Mobile & Cross Platform SDK Jun 20, 2024
@buenaflor buenaflor moved this from Todo to Needs Review in Mobile & Cross Platform SDK Jul 10, 2024
@buenaflor buenaflor self-assigned this Jul 10, 2024
@github-project-automation github-project-automation bot moved this from Needs Review to Done in Mobile & Cross Platform SDK Jul 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants