Skip to content

fix(genai): prevent crash on Infinity and NaN in AI config (#1264) - #1953

Open
abdelwahab-emad wants to merge 1 commit into
foss42:mainfrom
abdelwahab-emad:fix/1264-ai-config-infinity-v2
Open

abdelwahab-emad wants to merge 1 commit into
foss42:mainfrom
abdelwahab-emad:fix/1264-ai-config-infinity-v2

Conversation

@abdelwahab-emad

Copy link
Copy Markdown

PR Description

Prevents unhandled JsonUnsupportedObjectError / FormatException crashes when Infinity, -Infinity, NaN, or overflowing numeric values (such as 1e309) are entered into numeric AI configuration fields.

Changes

  • AIConfigField: Reject non-finite values (!parsed.isFinite) in onChanged and display 'Please enter a valid number' via TextFormField validation.
  • ConfigNumericValue: Guard constructor, deserialize, and getPayloadValue() against non-finite numbers so jsonEncode never receives Infinity or NaN.
  • Tests: Added unit tests in model_config_value_test.dart and widget tests in ai_config_test.dart.

Video Demo

Pr.video.mp4

Related Issues

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.

App crashes with unhandled exception when Infinity value is entered in AI config numeric fields

1 participant