Skip to content

Fix Dart native nullable number deserialization (#20238)#24386

Open
edwinnyawoli wants to merge 2 commits into
OpenAPITools:masterfrom
edwinnyawoli:fix/dart-nullable-number-deserialization-20238
Open

Fix Dart native nullable number deserialization (#20238)#24386
edwinnyawoli wants to merge 2 commits into
OpenAPITools:masterfrom
edwinnyawoli:fix/dart-nullable-number-deserialization-20238

Conversation

@edwinnyawoli

@edwinnyawoli edwinnyawoli commented Jul 22, 2026

Copy link
Copy Markdown

Fix Dart native serialization for optional number fields by guarding against null before calling num.parse(). Includes regression coverage in dart-native-deserialization-bugs.yaml and Dart client codegen tests.


Summary by cubic

Fix Dart native model deserialization to guard optional number fields (including non-nullable) against null before parsing, preventing crashes when JSON contains null. Adds regression tests covering OptionalNumberModel.problem.

  • Bug Fixes
    • Add null check before num.parse() for non-required numeric fields in dart2/serialization/native/native_class.mustache, regardless of nullable.
    • Add spec fixture and codegen test to assert the null guard in generated optional_number_model.dart.

Written for commit 662902c. Summary will update on new commits.

Review in cubic

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 3 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

@wing328

wing328 commented Jul 22, 2026

Copy link
Copy Markdown
Member

thanks for the PR

cc @jaumard (2018/09) @amondnet (2019/12) @sbu-WBT (2020/12) @kuhnroyal (2020/12) @agilob (2020/12) @ahmednfwela (2021/08)

please review the feedback from cubic-dev-ai to see if that's valid.

…on/native/native_class.mustache


This is actually valid

Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
@edwinnyawoli

Copy link
Copy Markdown
Author

@wing328 The feedback was actually valid so I've applied it

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants