Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shopify Product tags format is inconsistent between GET and POST #1173

Open
fmichaut-diff opened this issue Jun 21, 2023 · 4 comments
Open

Comments

@fmichaut-diff
Copy link

fmichaut-diff commented Jun 21, 2023

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_api version: 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

  1. Use the given code to reproduce the issue
  2. Notice that uncomenting the line makes the error go away
@github-actions
Copy link

This issue is stale because it has been open for 60 days with no activity. It will be closed if no further action occurs in 14 days.

@github-actions github-actions bot added the Stale label Aug 21, 2023
@fmichaut-diff
Copy link
Author

Not stale

@github-actions github-actions bot removed the Stale label Aug 22, 2023
@jaredbeck
Copy link

I can reproduce this issue in 13.1.0,

product = shop.execute_shopify_api { ShopifyAPI::Product.find(id: 7084933120074) }
product.tags #=> "foo"
product.save
# shopify_api-13.1.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: 7f494072-d3f9-46ce-ac60-60a5848feed8."} 
# (ShopifyAPI::Errors::HttpResponseError) 

product.tags = ['foo']
product.save # success

@jaredbeck
Copy link

The ShopifyAPI::Order object has a very similar issue with tags (perhaps exactly the same issue). It is reproducible in 13.1.0 using the same steps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants