r/FlutterDev • • 1d ago

Tooling I built an open-source self-healing bot for Flutter production crashes. Would love your architectural feedback on this concept.

https://pub.dev/packages/crash_pilot

Hi everyone,

Like most Flutter developers, I've spent too much time dealing with the standard production incident cycle: a fatal crash gets reported in Firebase Crashlytics, you pull the stack trace, reproduce it, write a defensive fix, run tests, and push a hotfix branch.

I wanted to see if we could automate this entire triage & verification pipeline without turning it into a black-box AI mess.

So I built and open-sourced **CrashPilot**: https://pub.dev/packages/crash_pilot

### How the pipeline works:

  1. **Crash Ingestion:** A webhook (Firebase Cloud Function / Sentry) catches a fatal crash trace and triggers a GitHub Actions workflow (`workflow_dispatch`).
  2. **Dart AST Extraction:** Instead of passing entire source files to an LLM, CrashPilot parses the Dart Abstract Syntax Tree (using `package:analyzer`) to isolate the exact enclosing method and class where the crash occurred.
  3. **Surgical Patching:** An LLM generates a minimal 5-15 line defensive replacement.
  4. **CI Sandbox Verification:** The patch is applied in an isolated headless Ubuntu runner, where it executes `flutter analyze` and `flutter test`. It uses an automated reflection loop (up to 3 turns) if compilation or tests fail.
  5. **Automated PR:** Once verified with 0 errors and passing tests, it pushes a branch and opens a GitHub Pull Request with a regression unit test and root-cause summary.

### Where it currently stands:

- Published on pub.dev (v1.0.9) with 160/160 pub points.

- Tested end-to-end on a demo repository where it successfully created verified PRs for null-check crashes.

- Source code: https://github.com/vaibhavbadhe712/crash_pilot

- Example demo PR generated by the bot: https://github.com/vaibhavbadhe712/crash_pilot_demo/pull/2

### What I want to ask the community:

Before I spend time expanding this, I’d love your honest feedback:

  1. **Does this concept sound practically useful for real-world production setups, or does auto-PR generation feel too risky?**
  2. What edge cases should I be most concerned about? (e.g. Obfuscated traces, multi-file state management like BLoC, or bad backend payloads masquerading as client crashes?)
  3. What feature would you consider essential before you'd ever test this on a real app?

Thanks for any insights, criticisms, or architectural suggestions!

0 Upvotes

1 comment sorted by

1

u/Ok_Gur_9033 1d ago

The step I'd worry about is 3 and 4 together. A 5 to 15 line defensive replacement for a null-check crash usually ends up as a ?? 0 or an early return, and flutter test will pass it, because the crash was the only thing failing. In my app the numbers that matter come from pure Dart functions, a weight trend and a protein target, and a fallback of 0 in one of those would turn a crash into a wrong number on screen that nobody reports.

What I'd want before trying it on a real app: the regression test asserts the value the method should return for the crashing input, it's written before the patch, and the PR gets refused if the patch only makes the crash go away. The other gap for me is step 1. The app has no crash reporting SDK at all, so there's nothing to ingest. Could it start from a stack trace pasted out of a user's email?