Shopify / Shopify/shopify-api-ruby

Bug in error handling in Shopify::Rest::Base#save

Open
#1,202 1 comment 0 reactions 1 assignee View on GitHub

@mllemango is already working on this.

Since Sep 5, 2023.

Dominant language
Ruby
Stars
1.1k
Forks
484
PR merge metrics
No merged PRs in 30d

Description

Issue summary

Since v13.0.0 ShopifyAPI::DiscountCode#errors signature has been changed to Hash, and #errors is initialized as Hash nil for DiscountCode resources.

This causes exception in error handling in ShopifyAPI::Rest::Base#save if ShopifyAPI::Errors::HttpResponseError is raised during save operation for DiscountCode resource. Exception is raised because Hash nil does not implement #errors

  • shopify_api version: 13.1.0
  • Ruby version: 2.7.7

Expected behavior

Rescuing from ShopifyAPI::Errors::HttpResponseError does not raise exception

Actual behavior

#<NoMethodError: undefined method `errors' for {}:Hash> is raised

#<NoMethodError: undefined method `errors' for nil:NilClass> is raised

Edit: corrected details

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.