Skip to content

fix(cli): Send the Flutter wizard's sample error only in debug builds - #2828

Merged
antonis merged 1 commit into
mainfrom
fix/flutter-wizard-debug-sample
Dec 3, 2026
Merged

antonis merged 1 commit into
mainfrom
fix/flutter-wizard-debug-sample

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

These four issues come from testing sentry wizard flutter on a fresh flutter create app (Flutter 3.44.1). All four also exist in @sentry/wizard 9.1.0.

1. The sample exception was sent on every launch, Release included. initSnippet now wraps it in if (kDebugMode) { … }, with the comment "Sends a sample error in debug builds. Remove these lines after confirming that your Sentry integration is working.", the same way the iOS (#2798) and Android (#2803) wizards now handle their test events. The default main.dart only imports package:flutter/material.dart, which doesn't make kDebugMode visible: widgets.dart re-exports only Brightness and UniqueKey from foundation.dart, and flutter analyze reports Undefined name 'kDebugMode' without the import. So patchMainContent adds import 'package:flutter/foundation.dart'; next to the Sentry import, unless the file already has an unprefixed import of it (with no show list, or one that includes kDebugMode). Existing import handling is unchanged. The outro now says the test error triggers when the app starts in debug mode.

2. sentry_dart_plugin exited 1 after a successful upload. Its commits step defaults to auto, so when the previous release's commit isn't in the local history (for example a shallow CI clone) set-commits fails with "Could not find the SHA of the previous release in the git history", and the whole command fails even though the debug symbols uploaded. The sentry: block now sets ignore_missing: true, with a comment. The plugin passes it to sentry-cli releases set-commits --ignore-missing, and that is the only place it's used.

3. upload_source_maps: true was written for mobile apps. It only matters for Flutter web; on mobile the plugin just logs "Skipping source maps upload". patchPubspec now writes it only when there's a web/ folder next to pubspec.yaml, and passes that to pubspecOptions. The copy-paste pubspec.yaml snippet uses the same check.

4. No Dart obfuscation map. The suggested build command now adds --extra-gen-snapshot-options=--save-obfuscation-map=build/app/obfuscation.map.json, and the sentry: block sets dart_symbol_map_path: build/app/obfuscation.map.json, so the plugin uploads the map and obfuscated names in exception messages and type names become readable. In the plugin, dart_symbol_map_path has to point at the file itself, not a directory. When the file is missing, the plugin logs "Skipping Dart symbol map uploads" and doesn't fail (lib/src/symbol_maps/dart_symbol_map.dart, lib/src/utils/path.dart). The plugin supports this upload on Android and iOS. flutter pub run sentry_dart_plugin stays as it is, because dart run failed in testing when a standalone Dart SDK came first on the PATH.

Open decision: this stays a draft until Antonis Lilis marks it ready for review.

via Antonis Lilis.

--

View Session [Sentry]

Found by testing `sentry wizard flutter` on a fresh `flutter create` app
(Flutter 3.44.1). All four also exist in `@sentry/wizard` 9.1.0.

- Wrap the sample exception in `if (kDebugMode)`, so shipped apps no
  longer send it on every launch. `material.dart` does not export
  `kDebugMode`, so `main.dart` gets `package:flutter/foundation.dart`
  unless it already imports it.
- Write `ignore_missing: true`, so `sentry_dart_plugin` does not exit 1
  after uploading when the previous release's commit is not in the local
  history, such as in a shallow CI clone.
- Write `upload_source_maps: true` only when the project has a `web/`
  folder.
- Suggest a build command that saves the Dart obfuscation map, and write
  `dart_symbol_map_path` so the plugin uploads it.

Co-Authored-By: Antonis Lilis <antonis.lilis@sentry.io>
@vercel

vercel Bot commented Dec 3, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
cli Ready Ready Preview Dec 3, 2026 8:25am UTC
1 Skipped Deployment
Project Deployment Actions Updated
sentry-local Skipped Skipped Dec 3, 2026 8:25am UTC

Request Review

@antonis
antonis marked this pull request as ready for review December 3, 2026 08:43
@antonis
antonis added this pull request to the merge queue Dec 3, 2026
@github-actions github-actions Bot added the risk: medium PR risk score: medium label Dec 3, 2026
Merged via the queue into main with commit f17f9bb Dec 3, 2026
33 checks passed
@antonis
antonis deleted the fix/flutter-wizard-debug-sample branch December 3, 2026 08:48

This branch was successfully deployed

1 active and 1 inactive deployments
Preview – cli — 4ebaf67a Deployed Dec 3, 2026 by vercel[bot]
Preview – sentry-local — 4ebaf67a Deployed Dec 3, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant