Shopify / Shopify/shopify-api-ruby
Shopify Product `tags` format is inconsistent between GET and POST
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 1.1k
- Forks
- 484
- PR merge metrics
- No merged PRs in 30d
Description
Issue summary
When we access product.tags it returns a string of comma separated tags.
When we save the product, it is required to set the tags to an array of tags.
This means that fetching a product and saving it without touching the tags results in an error :
product_id = XXX
ShopifyAPI::Auth::Session.temp(...) do
shopify_product = ShopifyAPI::Product.find(id: product_id)
# shopify_product.tags = shopify_product.tags.split(', ') # Uncomment this to fix the call
shopify_product.save!
end
# -> /usr/local/bundle/gems/shopify_api-13.0.0/lib/shopify_api/clients/http_client.rb:71:in `request': {"errors":{"product":"Required parameter missing or invalid"},"error_reference":"If you report this error, please include this id: f610c13a-c4ec-449d-b33f-1204e1eb2c3b."} (ShopifyAPI::Errors::HttpResponseError)
shopify_apiversion: 13.0.0- Ruby version: 3.2.0
- Operating system: MacOs 13.3.1
Expected behavior
The object returned by find or similar fetching methods should be in a state where they can be saved without the user having to map some fields (that he might not even be touching) in a different format.
Actual behavior
If you don't map the tags field from string to array, you can't save the product.
Steps to reproduce the problem
- Use the given code to reproduce the issue
- Notice that uncomenting the line makes the error go away
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 reproducing the issue with ShopifyAPI::Product.find and save!, then inspect the request path referenced at lib/shopify_api/clients/http_client.rb:71 and the product handling around tags. Done means a fetched product can be saved without manually converting tags from a comma-separated string to an array, with the existing reproduction no longer raising the shown error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100