Shopify / Shopify/shopify-api-ruby
Suggestion: Make it easier to identify or bypass only submitting dirty attributes on update
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 1.1k
- Forks
- 484
- PR merge metrics
- No merged PRs in 30d
Description
This feature to only send changed fields has tripped me up a few times and can be difficult to identify.
The problem I've ran into is when the object state hasn't changed and you call save it will still do the put request with an empty payload and you end up with an error with something like {"errors":{"metafield":"Required parameter missing or invalid"} which isn't very clear about the problem. As far as I can tell there isn't a method that I can use to inspect the object to decide if I need to save or not.
If this functionality is really important what do you think about a few additional features to make it easier to work with or bypass, such as:
- Allow bypassing the dirty attributes check and sending all attributes on
save. Maybe something likesave(only_changed: false) - Provide a method that we can use to inspect the object to see if there are changes so we can skip the
savecall if we want. Something likechanged?ordirty?maybe?
It would also be great if an error or warning of some sort was returned if the payload you are submitting is empty.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the dirty-attributes behavior introduced in PR 1149 and trace the save path that sends the PUT request. Define which proposed behavior is in scope—bypassing dirty checks, inspecting changes, or reporting empty payloads—and consider the issue complete when the selected behavior is specified with a clear way to verify it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100