Fix reset_password to handle wrapped API response #406
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.
Fixes issue where
reset_passwordreturned a User object with all nil fields despite successful API calls.Problem
Customer reported that after successfully resetting a password, the returned User object had all fields set to null:
Investigation revealed the WorkOS API returns password reset responses in wrapped format
{"user": {...}}, but the SDK was trying to parse it as a flat user object usingUser.new(response.body). This caused all fields to be nil because the User class looks for:id,:email, etc. at the top level, but they're nested under:user.Solution
Updated
reset_password(line 872) to useUserResponse.new(response.body).userto correctly unwrap the API response before extracting the User object.Testing & Verification
Changes
lib/workos/user_management.rb: Changed line 872 fromWorkOS::User.new(response.body)toWorkOS::UserResponse.new(response.body).userspec/support/fixtures/vcr_cassettes/user_management/reset_password/valid.yml: Updated response body to reflect wrapped format