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

Error "invalid event envelope" when send user feedback. #534

Closed
4 of 11 tasks
bgwastu opened this issue Jul 20, 2021 · 16 comments · Fixed by getsentry/sentry-java#1611 or #535
Closed
4 of 11 tasks

Error "invalid event envelope" when send user feedback. #534

bgwastu opened this issue Jul 20, 2021 · 16 comments · Fixed by getsentry/sentry-java#1611 or #535

Comments

@bgwastu
Copy link

bgwastu commented Jul 20, 2021

Platform:

  • Dart
  • Flutter Android or iOS
  • Flutter Web

IDE:

  • VSCode
  • IntelliJ/AS
  • XCode
  • Other, which one?

split-debug-info and obfuscate (Flutter Android or iOS) or CanvasKit (Flutter Web):

  • Enabled
  • Disabled

Platform installed with:

  • pub.dev
  • GitHub

Output of the command flutter doctor -v below:

[✓] Flutter (Channel stable, 2.2.3, on Microsoft Windows [Version 10.0.22000.71], locale id-ID)
    • Flutter version 2.2.3 at C:\SDK\flutter
    • Framework revision f4abaa0735 (3 weeks ago), 2021-07-01 12:46:11 -0700
    • Engine revision 241c87ad80
    • Dart version 2.13.4

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at C:\SDK\android
    • Platform android-31, build-tools 31.0.0
    • Java binary at: C:\Program Files\OpenJDK\jdk-11.0.8.10-hotspot\bin\java.exe
    • Java version OpenJDK Runtime Environment (build 11.0.8-internal+0-adhoc..jdk11u)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[!] Android Studio (not installed)
    • Android Studio not found; download from https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/docs/get-started/install/windows#android-setup for detailed instructions).

[✓] VS Code (version 1.58.2)
    • VS Code at C:\Users\Wastu\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.24.0

[✓] Connected device (3 available)
    • sdk gphone x86 (mobile) • emulator-5556 • android-x86    • Android 11 (API 30) (emulator)
    • Chrome (web)            • chrome        • web-javascript • Google Chrome 91.0.4472.164
    • Edge (web)              • edge          • web-javascript • Microsoft Edge 91.0.864.70

! Doctor found issues in 1 category.

The version of the SDK (See pubspec.lock):
6.0.0-beta.2


I have the following issue:
Error invalid event envelope when send user feedback.

Steps to reproduce:
When I call this code:

Sentry.captureUserFeedback(SentryUserFeedback(
            name: 'user name',
            email: '[email protected]',
            comments: 'feedback in here',
            eventId: SentryId.newId()));

I got error "API returned 400".

Actual result:

D/Sentry  (13608): Captured Envelope is already cached
D/Sentry  (13608): __unknown__ item 1 is being captured.
D/Sentry  (13608): Request failed, API returned 400
D/Sentry  (13608): {"detail":"invalid event envelope","causes":["invalid item header","missing field `type` at line 1 column 47"]}
D/Sentry  (13608): The transport failed to send the envelope with response code 400
E/Sentry  (13608): Envelope submission failed
E/Sentry  (13608): java.lang.IllegalStateException: The transport failed to send the envelope with response code 400
E/Sentry  (13608):      at io.sentry.transport.AsyncHttpTransport$EnvelopeSender.flush(AsyncHttpTransport.java:220)
E/Sentry  (13608):      at io.sentry.transport.AsyncHttpTransport$EnvelopeSender.run(AsyncHttpTransport.java:183)
E/Sentry  (13608):      at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:462)
E/Sentry  (13608):      at java.util.concurrent.FutureTask.run(FutureTask.java:266)
E/Sentry  (13608):      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
E/Sentry  (13608):      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
E/Sentry  (13608):      at java.lang.Thread.run(Thread.java:923)
D/Sentry  (13608): Marking envelope submission result: false
W/Sentry  (13608): Envelope had a failed capture at item 1. No more items will be sent.

Expected result:
User feedback sent to Sentry.

@ueman
Copy link
Collaborator

ueman commented Jul 20, 2021

You have to send user feedback for an event because user feedback is always linked to an event in Sentry.
So for example you need to do

final id = await Sentry.captureMessage('Hello World!'); // or Sentry.captureException(..), Sentry.captureEvent(..)
Sentry.captureUserFeedback(
    SentryUserFeedback(
            name: 'user name',
            email: '[email protected]',
            comments: 'feedback in here',
            eventId: id
    ),
);

If it still does not work after you changed it accordingly, then it is definitely a bug.

@bgwastu
Copy link
Author

bgwastu commented Jul 20, 2021

The same error still appears:

D/Sentry  (13608): Processing Envelope with 1 item(s)
I/tticdev.test(13608): Background young concurrent copying GC freed 56206(2754KB) AllocSpace objects, 7(128KB) LOS objects, 46% free, 3617KB/6707KB, paused 6.529ms total 59.911ms
D/Sentry  (13608): Capturing event: da1a1b32cc5442928c003cc3faab0ee9
I/Sentry  (13608): Not possible to read external files directory
D/Sentry  (13608): Captured Envelope is already cached
D/Sentry  (13608): Item 1 is being captured.
D/Sentry  (13608): Serializing object: {"level":"info","message":{"formatted":"Feedback"},"modules":{"StackWalker":"unknown","_fe_analyzer_shared":"unknown","abseil-cpp":"unknown","accessibility":"unknown","skia":"unknown","angle":"unknown","boringssl":"unknown","etc1":"unknown","khronos":"unknown","txt":"unknown","vulkan":"unknown","vulkan-deps":"unknown","wuffs":"unknown","base":"unknown","fuchsia_sdk":"unknown","zlib":"unknown","icu":"unknown","engine":"unknown","gpu":"unknown","tonic":"unknown","url_launcher_web":"unknown","analyzer":"unknown","rapidjson":"unknown","xxhash":"unknown","archive":"unknown","args":"unknown","async":"unknown","cli_util":"unknown","awesome_notifications":"unknown","background_fetch":"unknown","boolean_selector":"unknown","meta":"unknown","dart":"unknown","build":"unknown","build_runner":"unknown","code_builder":"unknown","web_socket_channel":"unknown","build_config":"unknown","io":"unknown","build_daemon":"unknown","ffi":"unknown","build_resolvers":"unknown","build_runner_core":"unknown","built_collection":"unknown","built_value":"unknown","characters":"unknown","checked_yaml":"unknown","package_config":"unknown","charcode":"unknown","fixnum":"unknown","glob":"unknown","http_parser":"unknown","matcher":"unknown","path":"unknown","pool":"unknown","pub_semver":"unknown","shelf_web_socket":"unknown","source_span":"unknown","stack_trace":"unknown","string_scanner":"unknown","watcher":"unknown","yaml":"unknown","clock":"unknown","fake_async":"unknown","collection":"unknown","mime":"unknown","stream_channel":"unknown","typed_data":"unknown","colorama":"unknown","convert":"unknown","crypto":"unknown","source_gen":"unknown","dart_style":"unknown","http":"unknown","shelf":"unknown","datetime_picker_formfield":"unknown","dio":"unknown","dio_cache_interceptor":"unknown","dio_cache_interceptor_hive_store":"unknown","double-conversion":"unknown","ffx_spd":"unknown","file":"unknown","files":"unknown","firebase":"unknown","firebase_analytics":"unknown","firebase_analytics_web":"unknown","firebase_core":"unknown","firebase_core_platform_interface":"unknown","firebase_messaging":"unknown","firebase_analytics_platform_interface":"unknown","package_info_plus":"unknown","firebase_core_web":"unknown","package_info_plus_linux":"unknown","package_info_plus_windows":"unknown","firebase_crashlytics":"unknown","firebase_crashlytics_platform_interface":"unknown","firebase_messaging_platform_interface":"unknown","firebase_messaging_web":"unknown","flutter":"unknown","flutter_easyloading":"unknown","flutter_native_splash":"unknown","flutter_spinkit":"unknown","flutter_svg":"unknown","freetype2":"unknown","frontend_server_client":"unknown","get":"unknown","glfw":"unknown","graphs":"unknown","json_annotation":"unknown","pedantic":"unknown","platform":"unknown","process":"unknown","stream_transform":"unknown","term_glyph":"unknown","harfbuzz":"unknown","hive":"unknown","hive_flutter":"unknown","hive_generator":"unknown","http_mock_adapter":"unknown","http_multi_server":"unknown","image":"unknown","internet_connection_checker":"unknown","intl":"unknown","logging":"unknown","shimmer":"unknown","js":"unknown","libcxx":"unknown","libcxxabi":"unknown","libjpeg-turbo":"unknown","libsdl":"unknown","libwebp":"unknown","lints":"unknown","mockito":"unknown","source_helper":"unknown","open_settings":"unknown","package_info_plus_macos":"unknown","package_info_plus_platform_interface":"unknown","package_info_plus_web":"unknown","path_drawing":"unknown","path_parsing":"unknown","path_provider":"unknown","path_provider_windows":"unknown","plugin_platform_interface":"unknown","url_launcher":"unknown","url_launcher_platform_interface":"unknown","path_provider_linux":"unknown","path_provider_platform_interface":"unknown","url_launcher_linux":"unknown","path_provider_macos":"unknown","petitparser":"unknown","xml":"unknown","pkg":"unknown","platform_detect":"unknown","pubspec_parse":"unknown","test_api":"unknown","timing":"unknown","root_certificates":"unknown","sentry":"unknown","sentry_flutter":"unknown","skcms":"unknown
D/Sentry  (13608): Serializing object: {"sid":"7f62c3e7-7ec4-4997-b78c-b361611e7176","did":"0f36b964-94e4-443e-a107-d801f0b8a72a","init":true,"started":"2021-07-20T05:55:55.086Z","status":"ok","timestamp":"2021-07-20T05:55:55.086Z","attrs":{"release":"[email protected]+1","environment":"debug"}}
D/Sentry  (13608): Envelope sent successfully.
D/Sentry  (13608): Envelope flushed
D/Sentry  (13608): Marking envelope submission result: true
D/Sentry  (13608): File '/data/user/0/com.atticdev.test/cache/sentry/outbox/9e62acfa-5b03-4b26-a735-0771163d5a06' is done.
D/Sentry  (13608): onEvent fired for EnvelopeFileObserver with event type 8 on path: /data/user/0/com.atticdev.test/cache/sentry/outbox for file 1b1ef25b-4e4a-41b5-8367-c6f61582c808.
D/Sentry  (13608): Processing Envelope with 1 item(s)
D/Sentry  (13608): Captured Envelope is already cached
D/Sentry  (13608): __unknown__ item 1 is being captured.
D/Sentry  (13608): Request failed, API returned 400
D/Sentry  (13608): {"detail":"invalid event envelope","causes":["invalid item header","missing field `type` at line 1 column 48"]}
D/Sentry  (13608): The transport failed to send the envelope with response code 400
E/Sentry  (13608): Envelope submission failed
E/Sentry  (13608): java.lang.IllegalStateException: The transport failed to send the envelope with response code 400
E/Sentry  (13608):      at io.sentry.transport.AsyncHttpTransport$EnvelopeSender.flush(AsyncHttpTransport.java:220)
E/Sentry  (13608):      at io.sentry.transport.AsyncHttpTransport$EnvelopeSender.run(AsyncHttpTransport.java:183)
E/Sentry  (13608):      at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:462)
E/Sentry  (13608):      at java.util.concurrent.FutureTask.run(FutureTask.java:266)
E/Sentry  (13608):      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
E/Sentry  (13608):      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
E/Sentry  (13608):      at java.lang.Thread.run(Thread.java:923)
D/Sentry  (13608): Marking envelope submission result: false
W/Sentry  (13608): Envelope had a failed capture at item 1. No more items will be sent.
D/Sentry  (13608): File '/data/user/0/com.atticdev.test/cache/sentry/outbox/1b1ef25b-4e4a-41b5-8367-c6f61582c808' is done.

@bgwastu
Copy link
Author

bgwastu commented Jul 20, 2021

The message appears in Issue which should be in user feedback.
image

@marandaneto
Copy link
Contributor

@ueman could be something with the envelope, can you have a look?

@ueman
Copy link
Collaborator

ueman commented Jul 20, 2021

The message appears in Issue which should be in user feedback.

@atticdev That's because you can't collect user feedback without an issue. Could it be that Feedback is the message which you captured?

@marandaneto I think it's an Android problem. Pure Dart, iOS and macOS are working fine.

@marandaneto
Copy link
Contributor

marandaneto commented Jul 20, 2021

@ueman yep, if you get the envelope String before it gets written to the disk on Android, I can try to debug too, maybe we're missing something since the Android SDK deserializes the envelope before it gets sent, different than iOS.

@bgwastu
Copy link
Author

bgwastu commented Jul 20, 2021

@ueman Ahh I see, I thought the user feedback sent directly to "User Feedback" menu in Sentry.

My current user feedback:
image

What should I do so that the feedback goes directly to the user feedback menu?

This is my full code:

Future<void> send() async {
    if (formKey.currentState!.validate()) {
      final name = nameController.text;
      final email = emailController.text;
      final feedback = feedbackController.text;

      try {
        final id = await Sentry.captureMessage('Feedback');
        Sentry.captureUserFeedback(SentryUserFeedback(
            name: name,
            email: email,
            comments: feedback,
            eventId: id));
            
        await EasyLoading.dismiss();
        await EasyLoading.showSuccess('Your feedback has been sent');
      } catch (_) {
        await EasyLoading.dismiss();
      }
    }
  }

@ueman
Copy link
Collaborator

ueman commented Jul 20, 2021

@marandaneto
On Android the incoming UserFeedback envelope from Dart looks like

{
    "event_id": "bdd63725a2b84c1eabd761106e17d390",
    "sdk": {
        "name": "sentry.dart.flutter",
        "version": "6.0.0-beta.3",
        "packages": [
            {
                "name": "pub:sentry",
                "version": "6.0.0-beta.3"
            },
            {
                "name": "pub:sentry_flutter",
                "version": "6.0.0-beta.3"
            }
        ],
        "integrations": [
            "isolateErrorIntegration",
            "runZonedGuardedIntegration",
            "widgetsFlutterBindingIntegration",
            "flutterErrorIntegration",
            "widgetsBindingIntegration",
            "nativeSdkIntegration",
            "loadAndroidImageListIntegration",
            "loadReleaseIntegration"
        ]
    }
}
{
    "content_type": "application/json",
    "type": "user_report",
    "length": 103
}
{
    "event_id": "bdd63725a2b84c1eabd761106e17d390",
    "name": "jonas",
    "email": "[email protected]",
    "comments": "bad stuff"
}

Do you see what's wrong?

@marandaneto
Copy link
Contributor

@ueman I'll have a look

@ueman
Copy link
Collaborator

ueman commented Jul 20, 2021

What should I do so that the feedback goes directly to the user feedback menu?

@atticdev It's currently broken on Android. It should show up after it's fixed. Until then you can try Flutter for Web or iOS.

@marandaneto
Copy link
Contributor

ok found out, looks like it's an Android bug, introduced by getsentry/sentry-java#1439
It's an easy fix but first I have to find out if I wont break anything else.

the thing is, type should be lower case, but Android capitalizes the String https://github.com/getsentry/sentry-java/blob/main/sentry/src/main/java/io/sentry/SentryEnvelopeItemHeaderAdapter.java#L72-L80

@marandaneto
Copy link
Contributor

or actually, because we have to convert from a String to an enum, but only with capitalization, User_report won't match UserFeedback

@marandaneto
Copy link
Contributor

@atticdev thanks for reporting, a fix is coming up soon.

@marandaneto
Copy link
Contributor

the fix on the underlying SDK is done, we've to release and bump the SDK version here.

@marandaneto
Copy link
Contributor

@atticdev thanks for reporting once more, please give it a try https://github.com/getsentry/sentry-dart/releases/tag/6.0.0-beta.3

@bgwastu
Copy link
Author

bgwastu commented Jul 29, 2021

Hi, @marandaneto

I have already use the updated package using git 3 days ago, and it works as expected, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants