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

ShopifyAPI::Errors::HttpResponseError ({"error_reference":"If you report this error, please include this id 136e7407-e353-4ecf-8a66-xxxxxxxxx #1229

Closed poojaskarale closed 12 months ago

poojaskarale commented 1 year ago

I am facing this issue when I am trying to save Shopify theme's settings- theme name - dawn 2.0 query - setting_datas = ShopifyAPI::Asset.all(session: shopify_session, asset: {key: 'config/settings_data.json'}, theme_id: publish_theme_id) setting_datas[0].save

error - ShopifyAPI::Errors::HttpResponseError ({"error_reference":"If you report this error, please include this id 136e7407-e353-4ecf-8a66-xxxxxxxxx

Please help me here

aryansharma-16 commented 1 year ago

Facing the same issue for Asset API since a month while writing and having same error for Metafield API since yesterday

nelsonwittwer commented 1 year ago

Am I correct in understanding these were 500 level errors that you are seeing this response to? If so, that would be an upstream problem from this library. Providing complete error tracing IDs help surface this problem to correct team. Can you provide the most recent error reference so I can provide that as context to our API team?

aryansharma-16 commented 1 year ago

hi @nelsonwittwer, following are the steps to reproduce this error

shop=Shop.last

shop.with_shopify_session do 
  @found_theme = ShopifyAPI::Theme.all&.find{|theme| theme.role == 'main'}
end

shop.with_shopify_session do
  asset = ShopifyAPI::Asset.all(theme_id: @found_theme.id, asset: {key: 'sections/main-product.liquid'}).last
  lines = asset.value.lines
  body = []
  lines.each do |line|
    body << line
    body << "{% comment %} a piece of code from codebase {% endcomment %}\n" if(line =~ /{%- case block.type -%}/)
  end
  asset.value = body.join
  asset.save!
end

this is giving following error gems/ruby-3.1.2/gems/shopify_api-13.1.0/lib/shopify_api/clients/http_client.rb:71:in `request': {"error_reference":"If you report this error, please include this id: 159f7eca-c122-4b02-8dda-7560b70c1365."} (ShopifyAPI::Errors::HttpResponseError)

while debugging, in repository I found the code below which eleminates the possibility of this error being 500-

unless [429, 500].include?(response.code)
      raise ShopifyAPI::Errors::HttpResponseError.new(response: response), error_message
 end
nelsonwittwer commented 1 year ago

Thanks @aryansharma-16 , I'm not able to find that ID in the logs. Can you give me a rough estimate as to when that request failed so I can better filter?

The fact that your error is a ShopifyAPI::Errors::HttpResponseError and that is the class of error we raise on 5xx errors as you've pointed out is what makes me suspect this a server error and not an error with the library. I can better confirm if I can find the log, so let me know when to set that filter date, thanks!

aryansharma-16 commented 1 year ago

@nelsonwittwer the ID 159f7eca-c122-4b02-8dda-7560b70c1365 I provided, I tried to execute it just before posting the comment here, i.e you can check logs for today also. In case you don't find that, here's another ID 82df3b5f-ed0f-4776-861a-f77e5f43f588 I tried this on 19th Oct Thanks

nelsonwittwer commented 1 year ago

Thanks! I see it in the log and can use this help to try and track down the root issue.

On Thu, Oct 26, 2023 at 9:37 AM aryansharma-16 @.***> wrote:

@nelsonwittwer https://github.com/nelsonwittwer the ID 159f7eca-c122-4b02-8dda-7560b70c1365 I provided, I tried to execute it just before posting the comment here, i.e you can check logs for today also. In case you don't find that, here's another ID 82df3b5f-ed0f-4776-861a-f77e5f43f588 I tried this on 19th Oct Thanks

— Reply to this email directly, view it on GitHub https://github.com/Shopify/shopify-api-ruby/issues/1229#issuecomment-1781146151 or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFZC7ZRRAIZYH4DJ3WH2RLYBJRSNBFKMF2HI4TJMJ2XIZLTSOBKK5TBNR2WLJDUOJ2WLJDOMFWWLO3UNBZGKYLEL5YGC4TUNFRWS4DBNZ2F6YLDORUXM2LUPGBKK5TBNR2WLJDUOJ2WLJDOMFWWLLTXMF2GG2C7MFRXI2LWNF2HTAVFOZQWY5LFUVUXG43VMWSG4YLNMWVXI2DSMVQWIX3UPFYGLLDTOVRGUZLDORPXI6LQMWWES43TOVSUG33NNVSW45FGORXXA2LDOOJIFJDUPFYGLKTSMVYG643JORXXE6NFOZQWY5LFUYZDENJUGYZYFJDUPFYGLJLJONZXKZNFOZQWY5LFVIYTSMZWG42TSNJYGOTXI4TJM5TWK4VGMNZGKYLUMU . You are receiving this email because you were mentioned.

Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub .

poojaskarale commented 1 year ago

@nelsonwittwer , here are the details -

3:49 am Friday, 27 October 2023 Coordinated Universal Time (UTC)

shop = Shop.find_by_shopify_domain('demo-hulk-pooja.myshopify.com') shopify_session = ShopifyAPI::Auth::Session.new(shop: shop.shopify_domain, access_token: shop.shopify_token) setting_datas = ShopifyAPI::Asset.all(session: shopify_session, asset: {key: 'config/settings_data.json'}, theme_id: theme_id) setting_data = setting_datas[0] setting_data.save!

error - Traceback (most recent call last): 1: from (irb):5 ShopifyAPI::Errors::HttpResponseError ({"error_reference":"If you report this error, please include this id: 71796e82-144e-4aa1-a5f2-2d1b7713ab6e."})

aryansharma-16 commented 1 year ago

hey @nelsonwittwer any updates? Is the issue tracked?

aryansharma-16 commented 12 months ago

hi @nelsonwittwer, is there any update on this? This is important for our app, I even tried finding it's alternative but can't find docs for how can I integrate theme app extensions with the app in rails framework.

When tried with curl, it's giving 404 {"errors":"Not Found"}

nelsonwittwer commented 12 months ago

After some digging I found out this endpoint is removed and is only supported for a select few users which is why the documentation is sparse / this endpoint is behaving strangely.

This page states

Starting with Admin API 2023-04, Asset resource PUT or DEL requests are restricted using the write_themes access scope. If an app that's distributed in the Shopify App Store needs to use Asset resource PUT or DEL requests, then it needs to be granted an exemption by Shopify to use the write_themes access scope.

404 from your curl is to be expected given the removal.

That page suggests looking at using theme app extensions which is what I'd recommend as well.

Given this is a deleted endpoint, I'm afraid we won't be able to investigate this issue further.

immakdas commented 8 months ago

I have permission to use Asset resource PUT or DEL requests in my app. So when I try to save the Asset with API 2023-10 and 2023-04 I get the errors like error: {"error_reference":"If you report this error, please include this id: b155c963-74e0-4014-8f23-6e610b2789c2."}

Could you please reopen the ticket and resolve the bug? Half of the Shopify merchants use old themes and we developers are required to use AssetAPI. (app already has theme-app-ext ....)

Hope the RUBY backtrace helps to find the cause

backtrace ["/.rvm/gems/ruby-3.2.2/gems/shopify_api-13.3.1/lib/shopify_api/clients/http_client.rb:75:in `request'", "/.rvm/gems/ruby-3.2.2/gems/sorbet-runtime-0.5.11150/lib/types/private/methods/call_validation_2_7.rb:108:in `bind_call'", "/.rvm/gems/ruby-3.2.2/gems/sorbet-runtime-0.5.11150/lib/types/private/methods/call_validation_2_7.rb:108:in `block in create_validator_method_fast1'", "/.rvm/gems/ruby-3.2.2/gems/shopify_api-13.3.1/lib/shopify_api/clients/rest/admin.rb:68:in `put'", "/.rvm/gems/ruby-3.2.2/gems/sorbet-runtime-0.5.11150/lib/types/private/methods/call_validation.rb:153:in `bind_call'", "/.rvm/gems/ruby-3.2.2/gems/sorbet-runtime-0.5.11150/lib/types/private/methods/call_validation.rb:153:in `validate_call_skip_block_type'", "/.rvm/gems/ruby-3.2.2/gems/sorbet-runtime-0.5.11150/lib/types/private/methods/call_validation.rb:95:in `block in create_validator_slow_skip_block_type'", "/.rvm/gems/ruby-3.2.2/gems/shopify_api-13.3.1/lib/shopify_api/rest/base.rb:345:in `public_send'", "/.rvm/gems/ruby-3.2.2/gems/shopify_api-13.3.1/lib/shopify_api/rest/base.rb:345:in `save'", "/.rvm/gems/ruby-3.2.2/gems/sorbet-runtime-0.5.11150/lib/types/private/methods/call_validation.rb:153:in `bind_call'", 
"/.rvm/gems/ruby-3.2.2/gems/sorbet-runtime-0.5.11150/lib/types/private/methods/call_validation.rb:153:in `validate_call_skip_block_type'", 
"/.rvm/gems/ruby-3.2.2/gems/sorbet-runtime-0.5.11150/lib/types/private/methods/call_validation.rb:95:in `block in create_validator_slow_skip_block_type'", ....