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: pass empty Locations and PrivateLocations to backend [sc-23129] #125

Conversation

sorccu
Copy link
Contributor

@sorccu sorccu commented Jan 31, 2025

When omitempty is specified for a property, the property is not sent to the server. Our PUT endpoints however act like PATCH would, meaning that partial updates are supported. When a property is not set, it is kept intact, even though the intention most likely was to remove it. Furthermore, using null value causes the same behavior as if the property was never given, so removing omitempty is not enough. Instead, we force empty Locations and PrivateLocations to always be sent as [] by initializing them as empty slices if not set.

The same issue likely exists for all other slices that have been marked omitempty. Whether they can also be changed or not requires some additional research. For now, only these two properties have been changed.

Affected Components

  • New Features
  • Bug Fixing
  • Types
  • Tests
  • Docs
  • Other

Style

  • Go code is formatted with go fmt

Notes for the Reviewer

Resolves #[issue-number]

New Dependency Submission

When omitempty, the property is not sent to the server. Our PUT endpoints
however act like PATCH would, meaning that partial updates are supported.
When a property is not set, it is kept intact, even though the intention
most likely was to remove it.
Antoine-C
Antoine-C previously approved these changes Jan 31, 2025
…t set

If the backend does not receive a value, or receives a null value, it will
not update the database. This is an issue for many other values too, but
as an API level fix will be needed, for now this patch only addresses the
fields we've received reports about.

To make the patch a little easier, Create now calls CreateCheck, Update
UpdateCheck and Delete DeleteCheck. The latter two were already equivalent.
Create and CreateCheck had some differences (mainly that that former would
send the request to /v1/checks instead of /v1/checks/<type>), but given
how CreateCheck covers all check types, there should be no difference.
@sorccu sorccu changed the title fix: remove omitempty from Locations and PrivateLocations [sc-23129] fix: pass empty Locations and PrivateLocations to backend [sc-23129] Feb 3, 2025
@sorccu sorccu merged commit 5b35b64 into main Feb 3, 2025
1 check passed
@sorccu sorccu deleted the simokinnunen/sc-23129/checkly-go-sdk-omitempty-for-locations-causes branch February 3, 2025 12:57
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.

2 participants