Skip to content

Apply StructTypes.defaults to missing fields after field 32 - #111

Open
quinnj-bot[bot] wants to merge 2 commits into
mainfrom
claude/wide-struct-defaults
Open

quinnj-bot[bot] wants to merge 2 commits into
mainfrom
claude/wide-struct-defaults

Conversation

@quinnj-bot

@quinnj-bot quinnj-bot Bot commented Nov 18, 2026

Copy link
Copy Markdown

Why

JSON3.read(json, T) throws Cannot convert an object of type Nothing when T has more than 32 fields and the JSON leaves out a field after the 32nd, even when StructTypes.defaults(T) gives that field a default. The same JSON works when the missing field is one of the first 32. The answer to #104 (fill an excluded field from StructTypes.defaults) fails on wide structs for this reason.

Refs #104.

What changed

  • StructTypes.construct(values::Vector{Any}, T) fills a missing field from StructTypes.defaults(T) for every field. Before, fields 33 and up got nothing.

Scope

  • Only the positional construct(values, T) path that JSON3 uses to read Struct types.
  • constructfrom(T, obj) from a struct or NamedTuple source still ignores defaults(T) for a missing field. That path never read defaults, and changing it is a behavior change rather than this fix.

Blast Radius

JSON3 is the caller. A missing field past field 32 that has no default still gets nothing, as before.

Verification

  • New test construct(values, T) applies defaults to every missing field errors before the fix with the convert MethodError and passes after.
  • Full suite passes on Julia 1.12 and 1.10 (macOS) and 1.6 (Docker julia:1.6).
  • With JSON3 1.14.4, reading a 34-field struct whose JSON omits field 34 now returns the default instead of throwing.

🤖 Generated with Claude Code

quinnj and others added 2 commits November 18, 2026 02:50
StructTypes.construct(values, T) fills a missing field from
StructTypes.defaults(T) only for the first 32 fields. A missing field
after that gets nothing, so JSON3.read fails on a wide struct.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@codecov

codecov Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.56%. Comparing base (916621a) to head (6c98cbf).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #111      +/-   ##
==========================================
+ Coverage   78.38%   81.56%   +3.17%     
==========================================
  Files           2        2              
  Lines         421      423       +2     
==========================================
+ Hits          330      345      +15     
+ Misses         91       78      -13     

☔ 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.

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.

1 participant