Fix request body construction to only send non-nil values #384
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Fix multiple methods in the UserManagement module to use
.compact
when building request bodies, preventing unnecessary nil values from being sent to the API.This addresses a customer-reported issue where
update_user
was unintentionally nullifying fields that weren't explicitly provided. The fix has been extended to all similar methods for consistency.What was the problem?
When calling methods like
update_user
with only some parameters:The method was sending ALL parameters (including nil ones) to the API:
This caused the API to explicitly nullify fields that users didn't intend to change.
What's the solution?
Add
.compact
to remove nil values before sending the request:Methods Fixed
update_user
- Critical fix for user-reported issuecreate_user
- Consistency and best practicesend_invitation
- Remove unnecessary nil invitation parametersenroll_auth_factor
- Remove unnecessary nil TOTP parameterscreate_organization_membership
- Remove unnecessary nil role_slugcreate_magic_auth
- Remove unnecessary nil invitation_token