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

fix(dns): keep comments intact with zero values of UpdateDNSRecordParams #1393

Merged
merged 2 commits into from Sep 12, 2023

Conversation

favonia
Copy link
Contributor

@favonia favonia commented Sep 10, 2023

Description

Calling UpdateDNSRecord with an (almost) zero value of UpdateDNSRecordParams will cause the existing comments to be erased. The solution is straightforward---change the type of the field Comment from string to &string, just like how the field Proxy has the type &bool instead of bool.

Closes #1371.

Has your change been tested?

Yes, but the test must be done against the real server. It is difficult to include a real test in the Go library.

Types of changes

What sort of change does your code introduce/modify?

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes. CAVEAT: A real test can only be done against the real API server, not against the mock server within the Go library.
  • All new and existing tests passed.
  • This change is using publicly documented in cloudflare/api-schemas
    and relies on stable APIs.

@github-actions
Copy link
Contributor

github-actions bot commented Sep 10, 2023

changelog detected ✅

dns_test.go Outdated Show resolved Hide resolved
dns_test.go Outdated Show resolved Hide resolved
@jacobbednarz
Copy link
Member

jacobbednarz commented Sep 11, 2023

did you manually confirm these API calls are working for your use case on the PATCH endpoint? this lgtm

@codecov-commenter
Copy link

codecov-commenter commented Sep 11, 2023

Codecov Report

Merging #1393 (e465b29) into master (b9ac804) will increase coverage by 0.08%.
Report is 261 commits behind head on master.
The diff coverage is 50.54%.

@@            Coverage Diff             @@
##           master    #1393      +/-   ##
==========================================
+ Coverage   48.33%   48.41%   +0.08%     
==========================================
  Files         133      139       +6     
  Lines       13023    13809     +786     
==========================================
+ Hits         6295     6686     +391     
- Misses       5201     5466     +265     
- Partials     1527     1657     +130     
Files Changed Coverage Δ
access_audit_log.go 79.31% <ø> (ø)
access_bookmark.go 72.44% <ø> (ø)
access_keys.go 71.42% <ø> (ø)
access_organization.go 53.84% <ø> (ø)
access_service_tokens.go 51.85% <ø> (ø)
account_members.go 65.54% <ø> (ø)
account_roles.go 53.84% <ø> (ø)
accounts.go 50.81% <ø> (ø)
addressing_address_map.go 39.04% <ø> (ø)
addressing_ip_prefix.go 45.45% <ø> (ø)
... and 121 more

... and 1 file with indirect coverage changes

@favonia favonia force-pushed the zeros-keep-comments branch 3 times, most recently from 0a59e86 to 7f15f6c Compare September 11, 2023 10:26
@favonia
Copy link
Contributor Author

favonia commented Sep 11, 2023

@jacobbednarz Thanks for the reminder. I did the tests about GetDNSRecord, UpdateDNSRecord and ListDNSRecords (but not CreateDNSRecord), and added some comments. (I actually made some mistake but the manual testing got it.) I decided to keep the type of the Comment field in DNSRecord, ListDNSRecordsParams and CreateDNSRecordParams as string (reverting my earlier commit in this PR), only changing that of UpdateDNSRecordParams to &string. The reason is that the server would omit the empty comment field when returning the results. I hope such inconsistency is okay.

@jacobbednarz
Copy link
Member

I hope such inconsistency is okay.

it is! and it only that, this is a shining example of where the CRUD operation specific params for a method allow us to make isolated changes without breaking all the method usages at once.

@favonia
Copy link
Contributor Author

favonia commented Sep 11, 2023

@jacobbednarz Personally I think this is ready to go!

@favonia favonia changed the title fix(dns): keep comments with zero values of UpdateDNSRecordParams fix(dns): keep comments intact with zero values of UpdateDNSRecordParams Sep 11, 2023
@jacobbednarz jacobbednarz merged commit a2982e7 into cloudflare:master Sep 12, 2023
11 checks passed
@jacobbednarz
Copy link
Member

thank you!

@github-actions github-actions bot added this to the v0.77.0 milestone Sep 12, 2023
github-actions bot pushed a commit that referenced this pull request Sep 12, 2023
@favonia favonia deleted the zeros-keep-comments branch September 12, 2023 04:38
@github-actions
Copy link
Contributor

This functionality has been released in v0.77.0.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Zero values of UpdateDNSRecordParams should keep the comments
3 participants