Skip to content

Conversation

MartinHH
Copy link
Contributor

@MartinHH MartinHH commented Apr 2, 2025

Fix superfluous keys not being ignored when decoding ADTs/Enums.

Fixes #2368

@codecov-commenter
Copy link

⚠️ 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 84.28%. Comparing base (1ea0e87) to head (db662f7).
Report is 1 commits behind head on series/0.14.x.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@                Coverage Diff                @@
##           series/0.14.x    #2369      +/-   ##
=================================================
+ Coverage          82.57%   84.28%   +1.71%     
=================================================
  Files                 94       75      -19     
  Lines               3712     2807     -905     
  Branches             590      368     -222     
=================================================
- Hits                3065     2366     -699     
+ Misses               647      441     -206     
Flag Coverage Δ
2.12 84.11% <ø> (-1.01%) ⬇️
2.13 84.33% <ø> (-0.94%) ⬇️
3 ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 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.

Copy link
Member

@zarthross zarthross left a comment

Choose a reason for hiding this comment

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

You need to check that conf.strictDecoding is false, when strict decoding is true the correct behavior is rejecting the json if it has extra fields.

@MartinHH
Copy link
Contributor Author

MartinHH commented Apr 3, 2025

You need to check that conf.strictDecoding is false, when strict decoding is true the correct behavior is rejecting the json if it has extra fields.

That's already checked. The only case where fromName(...) is called with (potentially) non-empty fallBacks is the else-branch of if iter.hasNext && conf.strictDecoding - see https://github.com/MartinHH/circe/blob/db662f79d231b3aa0475aa8756af10181e57615a/modules/core/shared/src/main/scala-3/io/circe/derivation/ConfiguredDecoder.scala#L87

Copy link
Member

@zarthross zarthross left a comment

Choose a reason for hiding this comment

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

Configuration#strictDecoding should fail for sum types when the json object has more than one field does look like it covers the area I was concerned about.

Thanks for your work!

@hamnis hamnis merged commit 81ee27f into circe:series/0.14.x Apr 3, 2025
18 checks passed
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.

Scala 3: incosistent behavior of Decoder for sealed traits in presence of additional fields.
4 participants