You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If Shopify responds with a 4xx or 5xx status code while creating a discount code via the REST API, then a NoMethodError is raised.
shopify_api version: 13.3.1
Ruby version: 3.2.2
Operating system: Ubuntu 22.04 LTS
Expected behavior
The DiscountCode resource should not set @errors to nil on initialization. It should leave it set from the base class as an instance of Rest::BaseErrors
When a ShopifyAPI::Errors::HttpResponseError is encountered during a save, the error is appended onto @errors.errors and the exception is re-raised
Since @errors is nil on the DiscountCode resource, we get the following:
NoMethodError: undefined method `errors' for nil:NilClass
Steps to reproduce the problem
Add the following test case to test/rest/2023_10/discount_code_test.rb and run it. It will blow up with the no method error I described:
sigdovoidenddeftest_10()stub_request(:post,"https://test-shop.myshopify.io/admin/api/2023-10/price_rules/507328175/discount_codes.json").to_return(status: 500,body: JSON.generate({"errors":[{"message":"There was a problem loading this website. Please try again.","extensions":{"code":"SERVICE_UNAVAILABLE"}}],"error_reference":"If you report this error, please include this id: 9e6928cf-99cd-47e0-a257-b335115453dc."}),headers: {})response=discount_code=ShopifyAPI::DiscountCode.newdiscount_code.price_rule_id=507328175discount_code.code="SUMMERSALE10OFF"discount_code.save!end
The text was updated successfully, but these errors were encountered:
Issue summary
If Shopify responds with a 4xx or 5xx status code while creating a discount code via the REST API, then a
NoMethodError
is raised.shopify_api
version: 13.3.1Expected behavior
DiscountCode
resource should not set@errors
tonil
on initialization. It should leave it set from the base class as an instance ofRest::BaseErrors
ShopifyAPI::Errors::HttpResponseError
is encountered during a save, the error is appended onto@errors.errors
and the exception is re-raisedActual behavior
ShopifyAPI::Rest::Base
class, an@errors
variable is initializedShopifyAPI::DiscountCode
resource, the initializer resets@errors
to nilShopifyAPI::Errors::HttpResponseError
is encountered while saving, we append the error onto@errors.errors
@errors
isnil
on theDiscountCode
resource, we get the following:Steps to reproduce the problem
Add the following test case to
test/rest/2023_10/discount_code_test.rb
and run it. It will blow up with the no method error I described:The text was updated successfully, but these errors were encountered: