Skip to content

fix(mix): report FlutterErrorDetails in debug mode when Prop value conversion fails - #1096

Open
leoafarias wants to merge 3 commits into
mainfrom
fix/prop-conversion-flutter-error
Open

leoafarias wants to merge 3 commits into
mainfrom
fix/prop-conversion-flutter-error

Conversation

@leoafarias

@leoafarias leoafarias commented Oct 15, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Replaces the silent debugPrint('Mix: could not convert value of type ...') inside assert in Prop.resolveProp with FlutterError.reportError(FlutterErrorDetails(...)) so that failed Mix<V> conversions surface through Flutter's standard error pipeline (FlutterError.onError) in debug/test mode while still returning the fallback resolved value without crashing the widget build.

Root Cause & Motivation

When a Prop<V> accumulates both a Mix<V> source (e.g. a custom Mix<double> subclass passed via Prop.mix(...)) and a plain value source (ValueSource<V> or TokenSource<V> resolving to V), hasMixValues is true and Prop.resolveProp converts every non-Mix<V> entry via MixConverterRegistry.instance.tryConvert<V>(value).

Previously, when no MixConverter<V> was registered (such as for scalar double), Prop.resolveProp only called debugPrint inside an assert block and silently dropped the unconverted value. Because debugPrint does not route through FlutterError.onError, invalid Mix<V> + scalar V combinations went unnoticed in flutter test while printing console noise on every animation frame.

Using FlutterError.reportError(FlutterErrorDetails(...)) inside the assert(() { ... return true; }()) block follows Flutter's standard non-fatal error reporting pattern (like RenderFlex overflow):

  • Never crashes in production or debug: resolveProp continues and returns the resolved fallback value in both debug and release builds instead of throwing mid-build.
  • Zero overhead in release/profile builds: The assert block is stripped in release builds.
  • Fails flutter test automatically: TestWidgetsFlutterBinding hooks FlutterError.onError, so widget tests fail immediately (and tester.takeException() captures the FlutterError).

Verification

  • Added unit test in packages/mix/test/src/core/prop_test.dart verifying that merging a ValueSource<double> with a custom Mix<double> reports FlutterErrorDetails via FlutterError.onError and still returns the resolved fallback value (20.0).
  • flutter test test/src/core/prop_test.dart
  • dart analyze lib/src/core/prop.dart test/src/core/prop_test.dart

@github-actions github-actions Bot added the mix label Oct 15, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-15T20:57:52.262859Z 328b63d New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@leoafarias leoafarias changed the title fix(mix): throw FlutterError in debug mode when Prop value conversion fails fix(mix): report FlutterErrorDetails in debug mode when Prop value conversion fails Oct 15, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a9c8f1ad49

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

debugPrint(
'Mix: could not convert value of type ${value.runtimeType} '
'to Mix<$V>. Register a MixConverter for <$V> or pass a Mix via Prop.mix.',
FlutterError.reportError(

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Throw instead of only reporting conversion failures

When a converter is missing in a debug build, FlutterError.reportError invokes the global FlutterError.onError handler and then returns; it does not throw. Consequently, resolveProp still drops the unconverted value and returns the remaining Mix result, and a handler can swallow the error exactly as this new test does, so the intended fail-fast behavior is not implemented. Throw the FlutterError from the assertion block and test with throwsA if resolution is meant to abort.

Useful? React with 👍 / 👎.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant