Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support persisting empty fields in StructToData #3362

Merged
merged 1 commit into from
Mar 15, 2024
Merged

Support persisting empty fields in StructToData #3362

merged 1 commit into from
Mar 15, 2024

Conversation

mgyucht
Copy link
Contributor

@mgyucht mgyucht commented Mar 11, 2024

Changes

Some APIs legitimately return empty objects in fields, but StructToData does not persist these objects (e.g. #3351). This is caused by a filter in collectionToMaps that removes data structures that don't have any non-optional fields or optional fields set to a non-empty/non-nil value.

This PR removes this check. I need to do a bit more work to verify the impact of removing this on the rest of the provider.

Tests

  • make test run locally
  • relevant change in docs/ folder
  • covered with integration tests in internal/acceptance
  • relevant acceptance tests are passing
  • using Go SDK

@mgyucht mgyucht requested review from a team as code owners March 11, 2024 21:37
@mgyucht mgyucht requested review from hectorcast-db and removed request for a team March 11, 2024 21:37
@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.44%. Comparing base (d29070e) to head (6617754).
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3362      +/-   ##
==========================================
+ Coverage   83.43%   83.44%   +0.01%     
==========================================
  Files         176      176              
  Lines       16219    16221       +2     
==========================================
+ Hits        13532    13536       +4     
+ Misses       1865     1864       -1     
+ Partials      822      821       -1     
Files Coverage Δ
common/reflect_resource.go 84.09% <ø> (+0.32%) ⬆️

... and 1 file with indirect coverage changes

Copy link
Contributor

@alexott alexott left a comment

Choose a reason for hiding this comment

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

thank you!

@hectorcast-db
Copy link
Contributor

We should be careful of APIs which "default" to empty structs / do not differentiate between not-set and empty struct.
If a user does not set the value, and the API returns an empty struct, there will be always a diff.

@alexott
Copy link
Contributor

alexott commented Mar 13, 2024

@hectorcast-db can we merge it, or we need to work on it further?

@hectorcast-db
Copy link
Contributor

@alexott @mgyucht
We discussed offline. It looks good to me, but I think that @mgyucht still wanted to run some tests.

@mgyucht
Copy link
Contributor Author

mgyucht commented Mar 15, 2024

I was concerned that this might exacerbate some issues with suppress diff, as it is will add empty dictionaries into state which might need diff suppression. However, I realized that that would only be needed if the API returned non-nil/empty values, which would always end up in the state anyways. So I think that isn't a concern, so we can merge this.

@mgyucht mgyucht added this pull request to the merge queue Mar 15, 2024
Merged via the queue into main with commit ce43ce3 Mar 15, 2024
5 checks passed
@mgyucht mgyucht deleted the issue-3351 branch March 15, 2024 16:37
@hectorcast-db hectorcast-db mentioned this pull request Mar 28, 2024
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.

4 participants