Skip to content

Fix TOML null handling and nested value serialization - #1965

Open
jump-oss wants to merge 1 commit into
datafaker-net:mainfrom
jump-oss:fix/toml-serialization-edge-cases
Open

jump-oss wants to merge 1 commit into
datafaker-net:mainfrom
jump-oss:fix/toml-serialization-edge-cases

Conversation

@jump-oss

Copy link
Copy Markdown
Contributor

Summary

Fixes #1955.

Fix six existing TOML serialization issues, following up on #1956:

  • Omit fields whose values are null, including nullable schema and array-of-tables fields, as discussed in Fix TOML key and table header escaping #1956.
  • Reject null field names and null elements in Java arrays or collections at any nesting depth with IllegalArgumentException. Error messages include the field path and element index where applicable.
  • Write ordinary assignments before table and array-of-tables headers at each schema level, so fields remain in their intended table.
  • Handle Java arrays and collections consistently: serialize all-Schema containers as arrays of tables and reject containers mixing Schema with ordinary values. Mixed ordinary scalar types remain supported.
  • Serialize non-finite Float and Double values as nan, inf, and -inf.
  • Serialize nested arrays and collections recursively instead of converting them to strings. Schema values inside nested arrays use inline tables.

Literal "null" strings, empty strings, and empty containers remain valid. Non-null schemas whose fields are all omitted retain their empty table structure, including their positions in arrays of tables.

Field suppliers are evaluated once per unique field at each schema occurrence. Relative order is preserved within ordinary assignments and within table fields.

Tests

Added regression tests using a test-scoped TOML parser to verify parsed structure, value types, element counts and order, null handling, and supplier invocation counts.

Verified locally with Java 17:

  • .\mvnw.cmd -B "-Dtest=TomlTest,TomlSerializationTest" test -PnoGpg — 378 tests passed.
  • .\mvnw.cmd -B clean test -PnoGpg — 21,856 tests passed, with no failures, errors, or skipped tests.
  • git diff --check — passed.

@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.50%. Comparing base (e153529) to head (b809a5e).
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #1965      +/-   ##
============================================
+ Coverage     92.43%   92.50%   +0.07%     
- Complexity     3584     3602      +18     
============================================
  Files           348      348              
  Lines          7084     7116      +32     
  Branches        695      711      +16     
============================================
+ Hits           6548     6583      +35     
+ Misses          370      369       -1     
+ Partials        166      164       -2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TomlTransformer emits unsupported null literals for null values and array elements

2 participants