Skip to content

Bug Report: loadContextsIntegration fails due to int → double? mismatch in SentryDevice.fromJson #3317

@StigUK

Description

@StigUK

Platform

Flutter Mobile Android

Obfuscation

Disabled

Debug Info

Disabled

Doctor

[✓] Flutter (Channel stable, 3.32.8, on macOS 26.0.1 25A362 darwin-arm64, locale uk-UA) [601ms]
• Flutter version 3.32.8 on channel stable at /Users/username/Documents/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision edada7c56e (3 months ago), 2025-07-25 14:08:03 +0000
• Engine revision ef0cd00091
• Dart version 3.8.1
• DevTools version 2.45.1

[!] Android toolchain - develop for Android devices (Android SDK version 35.0.0) [640ms]
• Android SDK at /Users/username/Library/Android/sdk
✗ cmdline-tools component is missing.
Try installing or updating Android Studio.
Alternatively, download the tools from https://developer.android.com/studio#command-line-tools-only and make sure to set the ANDROID_HOME environment variable.
See https://developer.android.com/studio/command-line for more details.
✗ Android license status unknown.
Run flutter doctor --android-licenses to accept the SDK licenses.
See https://flutter.dev/to/macos-android-setup for more details.

[✓] Xcode - develop for iOS and macOS (Xcode 26.0.1) [1 355ms]
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 17A400
• CocoaPods version 1.16.2

[✓] Chrome - develop for the web [9ms]
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2025.1) [8ms]
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 21.0.8+-14018985-b1038.68)

[✓] VS Code (version 1.101.2) [7ms]
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension can be installed from:
🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

Version

9.7.0

Steps to Reproduce

  1. Create or run a Flutter app with Sentry Flutter SDK integrated.
  2. Enable loadContextsIntegration (default behavior).
  3. Run the app on a physical device.
  4. Observe the Sentry logs in the console.

(Device: One Plus 8 Pro, Android 13)

Expected Result

Sentry should successfully load and merge device contexts without type errors.
The app should start normally, and events or transactions should be captured and sent to Sentry even if numeric context values (e.g. screen_density, battery_level) are integers in JSON.

Actual Result

When initializing Sentry Flutter SDK, the following error occurs during context loading:

[sentry] [error] loadContextsIntegration failed
type 'int' is not a subtype of type 'double?'
#0 new SentryDevice.fromJson (package:sentry/src/protocol/sentry_device.dart:199:26)
#1 new Contexts.fromJson (package:sentry/src/protocol/contexts.dart:44:26)
#2 _mergeNativeWithLocalContexts (package:sentry_flutter/src/integrations/load_contexts_integration.dart:267:37)
#3 _LoadContextsIntegrationEventProcessor.apply (package:sentry_flutter/src/integrations/load_contexts_integration.dart:120:7)
...

Are you willing to submit a PR?

None

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions