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

Open
clementperineau opened this issue Jun 12, 2024 · 2 comments
Open

setExtra while configuring scope throw ClassCastException #2098

clementperineau opened this issue Jun 12, 2024 · 2 comments

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Status: Todo
Development

No branches or pull requests

2 participants