Shopify / shopify-api-ruby

ShopifyAPI is a lightweight gem for accessing the Shopify admin REST and GraphQL web services.
MIT License
1.06k stars 473 forks source link

Patch bug with newly added attributes after resource creation #1197

Closed nelsonwittwer closed 1 year ago

nelsonwittwer commented 1 year ago

Description

As mentioned in #1164, change tracking for associated records is prone to errors. Especially when modifying a has_many association.

The root cause was an erroneous implementation of HashDiff#left_diff when removing or adding associated objects. When the key wasn't present in the original, which HashDiff#left_diff would return a {0=> HashDiff::NO_VALUE} as the value, we will now return whatever the current state of the object is since the original state didn't have that key.

How has this been tested?

Unit test + recreating reports in console.

Checklist:

nelsonwittwer commented 1 year ago

@mvanholstyn - I'm going to do more testing to verify this fix, but you would mind testing this solution with your workflow as well?

nelsonwittwer commented 1 year ago

Looking at the reported issue, it looks like we need to also make sure we are sending the required IDs. I'll add that fix as well here before getting review.

Edit - this is going to be trickier than I had hoped and will need a change to our REST resources. Moving ahead with this change for now to fix the new attributes