Skip to content

fix(flutter): Allow empty associatedEventId in SentryFeedbackForm - #4108

Merged
buenaflor merged 2 commits into
mainfrom
lz/fix/issue-4042
Oct 22, 2026
Merged

buenaflor merged 2 commits into
mainfrom
lz/fix/issue-4042

Conversation

@lucas-zimerman

Copy link
Copy Markdown
Collaborator

📜 Description

SentryFeedbackForm no longer asserts that associatedEventId is not SentryId.empty(). An empty id is now normalized to null in the constructor, so the form opens without an event association instead of crashing.

Because the normalization happens on the stored field, the empty id is also not sent with the submitted SentryFeedback, nor carried into pendingAssociatedEventId across the screenshot flow.

The public constructor and show signatures are unchanged.

💡 Motivation and Context

Fixes #4042

Hub.captureMessage / captureEvent return SentryId.empty() whenever the capture isn't sent (network error, disabled hub, dropped by an event processor or beforeSend). A common pattern — including the example app's "Capture Feedback" button — passes that id straight to SentryFeedbackForm.show, which crashed debug and profile builds with:

Failed assertion: 'associatedEventId != const SentryId.empty()': is not true.

This is a runtime/environmental condition, not a programmer error, so it shouldn't be an assert.

💚 How did you test it?

  • Added a widget test, submits feedback without association when associatedEventId is empty, that builds the form with SentryId.empty(), submits it, and verifies captureFeedback receives associatedEventId == null. It failed on the assertion before the fix and passes after.
  • flutter test test/feedback/ — all 59 tests pass.
  • flutter analyze --fatal-warnings and dart format (Dart 3.13) clean via the pre-commit hook.

📝 Checklist

  • I reviewed submitted code
  • I added tests to verify changes
  • No new PII added or SDK only sends newly added PII if sendDefaultPii is enabled
  • I updated the docs if needed
  • All tests passing
  • Public API changes reviewed by another Mobile SDK team member or implemented according to the develop docs spec
  • No breaking changes

🔮 Next steps

SentryFeedbackForm asserted that associatedEventId is never
SentryId.empty(), but Hub.captureMessage/captureEvent return the
empty id whenever the capture is not sent (network error, disabled
hub, beforeSend drop). Opening the form with that id crashed debug
and profile builds.

Treat an empty id the same as null (no association) instead.

Fixes #4042

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

Semver Impact of This PR

🟢 Patch (bug fixes)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


Features

Flutter

  • Report the generation of the cellular network technology in device.connection_effective_type on Android and iOS, for example 4g or 5g. On Android 11 and earlier, the app must have the READ_PHONE_STATE permission. by alwx in #4066
  • 🤖 Generated with Claude Code by alwx in #4066

Fixes

  • (flutter) Allow empty associatedEventId in SentryFeedbackForm by lucas-zimerman in #4108

Dependencies

  • chore(deps): update Native SDK to v0.17.4 by github-actions in #4093

🤖 This preview updates automatically when you update the PR.

@codecov

codecov Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.94%. Comparing base (54f7a7a) to head (01b1709).
⚠️ Report is 2 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4108      +/-   ##
==========================================
+ Coverage   88.81%   92.94%   +4.13%     
==========================================
  Files         348      114     -234     
  Lines       12631     4636    -7995     
==========================================
- Hits        11218     4309    -6909     
+ Misses       1413      327    -1086     
Flag Coverage Δ
sentry ?
sentry_dio ?
sentry_drift ?
sentry_file ?
sentry_firebase_remote_config 100.00% <ø> (ø)
sentry_flutter 92.66% <100.00%> (-0.03%) ⬇️
sentry_grpc ?
sentry_hive ?
sentry_isar ?
sentry_link ?
sentry_logging ?
sentry_sqflite ?
sentry_supabase 97.48% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@buenaflor
buenaflor enabled auto-merge (squash) October 22, 2026 10:30
@buenaflor
buenaflor merged commit 5acdb18 into main Oct 22, 2026
68 checks passed
@buenaflor
buenaflor deleted the lz/fix/issue-4042 branch October 22, 2026 10:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SentryFeedbackForm crashes on assert when associatedEventId capture failed

2 participants