Shopify Connector Error: UnicodeEncodeError:

Hi,

I’m receiving the following error log when I want to create/update articles or want to deactivate shopify settings:

App Versions

{
	"ecommerce_integrations": "1.7.4",
	"erpnext": "13.24.0",
	"frappe": "13.24.0"
}

Route

Form/Shopify Setting/Shopify Setting

Trackeback

Traceback (most recent call last):
  File "apps/frappe/frappe/desk/form/save.py", line 21, in savedocs
    doc.save()
  File "apps/frappe/frappe/model/document.py", line 287, in save
    return self._save(*args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 324, in _save
    self.run_before_save_methods()
  File "apps/frappe/frappe/model/document.py", line 971, in run_before_save_methods
    self.run_method("validate")
  File "apps/frappe/frappe/model/document.py", line 869, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1161, in composer
    return composed(self, method, *args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1144, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "apps/frappe/frappe/model/document.py", line 866, in fn
    return method_object(*args, **kwargs)
  File "apps/ecommerce_integrations/ecommerce_integrations/shopify/doctype/shopify_setting/shopify_setting.py", line 42, in validate
    self._handle_webhooks()
  File "apps/ecommerce_integrations/ecommerce_integrations/shopify/doctype/shopify_setting/shopify_setting.py", line 70, in _handle_webhooks
    connection.unregister_webhooks(self.shopify_url, self.get_password("password"))
  File "apps/ecommerce_integrations/ecommerce_integrations/shopify/connection.py", line 67, in unregister_webhooks
    for webhook in Webhook.find():
  File "env/lib/python3.7/site-packages/shopify/base.py", line 211, in find
    collection = super(ShopifyResource, cls).find(id_=id_, from_=from_, **kwargs)
  File "env/lib/python3.7/site-packages/pyactiveresource/activeresource.py", line 386, in find
    return cls._find_every(from_=from_, **kwargs)
  File "env/lib/python3.7/site-packages/pyactiveresource/activeresource.py", line 525, in _find_every
    response = cls.connection.get(path, cls.headers)
  File "env/lib/python3.7/site-packages/pyactiveresource/connection.py", line 329, in get
    return self._open('GET', path, headers=headers)
  File "env/lib/python3.7/site-packages/shopify/base.py", line 27, in _open
    self.response = super(ShopifyConnection, self)._open(*args, **kwargs)
  File "env/lib/python3.7/site-packages/pyactiveresource/connection.py", line 286, in _open
    http_response = self._handle_error(self._urlopen(request))
  File "env/lib/python3.7/site-packages/pyactiveresource/connection.py", line 316, in _urlopen
    return urllib.request.urlopen(request, timeout=self.timeout)
  File "/usr/lib/python3.7/urllib/request.py", line 222, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python3.7/urllib/request.py", line 525, in open
    response = self._open(req, data)
  File "/usr/lib/python3.7/urllib/request.py", line 543, in _open
    '_open', req)
  File "/usr/lib/python3.7/urllib/request.py", line 503, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.7/urllib/request.py", line 1393, in https_open
    context=self._context, check_hostname=self._check_hostname)
  File "/usr/lib/python3.7/urllib/request.py", line 1350, in do_open
    encode_chunked=req.has_header('Transfer-encoding'))
  File "/usr/lib/python3.7/http/client.py", line 1281, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib/python3.7/http/client.py", line 1322, in _send_request
    self.putheader(hdr, value)
  File "/usr/lib/python3.7/http/client.py", line 1254, in putheader
    values[i] = one_value.encode('latin-1')
UnicodeEncodeError: 'latin-1' codec can't encode characters in position 0-33: ordinal not in range(256)

Traceback (most recent call last):
  File "apps/frappe/frappe/app.py", line 68, in application
    response = frappe.api.handle()
  File "apps/frappe/frappe/api.py", line 55, in handle
    return frappe.handler.handle()
  File "apps/frappe/frappe/handler.py", line 31, in handle
    data = execute_cmd(cmd)
  File "apps/frappe/frappe/handler.py", line 68, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
  File "apps/frappe/frappe/__init__.py", line 1213, in call
    return fn(*args, **newargs)
  File "apps/frappe/frappe/desk/form/save.py", line 21, in savedocs
    doc.save()
  File "apps/frappe/frappe/model/document.py", line 287, in save
    return self._save(*args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 324, in _save
    self.run_before_save_methods()
  File "apps/frappe/frappe/model/document.py", line 971, in run_before_save_methods
    self.run_method("validate")
  File "apps/frappe/frappe/model/document.py", line 869, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1161, in composer
    return composed(self, method, *args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1144, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "apps/frappe/frappe/model/document.py", line 866, in fn
    return method_object(*args, **kwargs)
  File "apps/ecommerce_integrations/ecommerce_integrations/shopify/doctype/shopify_setting/shopify_setting.py", line 42, in validate
    self._handle_webhooks()
  File "apps/ecommerce_integrations/ecommerce_integrations/shopify/doctype/shopify_setting/shopify_setting.py", line 70, in _handle_webhooks
    connection.unregister_webhooks(self.shopify_url, self.get_password("password"))
  File "apps/ecommerce_integrations/ecommerce_integrations/shopify/connection.py", line 67, in unregister_webhooks
    for webhook in Webhook.find():
  File "env/lib/python3.7/site-packages/shopify/base.py", line 211, in find
    collection = super(ShopifyResource, cls).find(id_=id_, from_=from_, **kwargs)
  File "env/lib/python3.7/site-packages/pyactiveresource/activeresource.py", line 386, in find
    return cls._find_every(from_=from_, **kwargs)
  File "env/lib/python3.7/site-packages/pyactiveresource/activeresource.py", line 525, in _find_every
    response = cls.connection.get(path, cls.headers)
  File "env/lib/python3.7/site-packages/pyactiveresource/connection.py", line 329, in get
    return self._open('GET', path, headers=headers)
  File "env/lib/python3.7/site-packages/shopify/base.py", line 27, in _open
    self.response = super(ShopifyConnection, self)._open(*args, **kwargs)
  File "env/lib/python3.7/site-packages/pyactiveresource/connection.py", line 286, in _open
    http_response = self._handle_error(self._urlopen(request))
  File "env/lib/python3.7/site-packages/pyactiveresource/connection.py", line 316, in _urlopen
    return urllib.request.urlopen(request, timeout=self.timeout)
  File "/usr/lib/python3.7/urllib/request.py", line 222, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python3.7/urllib/request.py", line 525, in open
    response = self._open(req, data)
  File "/usr/lib/python3.7/urllib/request.py", line 543, in _open
    '_open', req)
  File "/usr/lib/python3.7/urllib/request.py", line 503, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.7/urllib/request.py", line 1393, in https_open
    context=self._context, check_hostname=self._check_hostname)
  File "/usr/lib/python3.7/urllib/request.py", line 1350, in do_open
    encode_chunked=req.has_header('Transfer-encoding'))
  File "/usr/lib/python3.7/http/client.py", line 1281, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib/python3.7/http/client.py", line 1322, in _send_request
    self.putheader(hdr, value)
  File "/usr/lib/python3.7/http/client.py", line 1254, in putheader
    values[i] = one_value.encode('latin-1')
UnicodeEncodeError: 'latin-1' codec can't encode characters in position 0-33: ordinal not in range(256)

Request Data

{
	"type": "POST",
	"args": {
		"doc": "{\"name\":\"Shopify Setting\",\"owner\":\"oke.brandt@liquam.com\",\"creation\":\"2022-03-25 14:36:22.793365\",\"modified\":\"2022-04-04 11:06:08.135653\",\"modified_by\":\"oke.brandt@liquam.com\",\"idx\":\"0\",\"docstatus\":0,\"enable_shopify\":0,\"shopify_url\":\"okeokelele.myshopify.com/\",\"password\":\"*****\",\"shared_secret\":\"267927364df762b754f675c9cb2c51d3\",\"default_customer\":\"Standardkunde Shopify\",\"customer_group\":\"Shopify Kunden\",\"company\":\"Liquam\",\"cash_bank_account\":\"Sparkasse Westholstein - LIQ\",\"cost_center\":\"Haupt - LIQ\",\"sales_order_series\":\"SAL-ORD-.YYYY.-\",\"sync_delivery_note\":0,\"sync_sales_invoice\":1,\"sales_invoice_series\":\"ACC-SINV-.YYYY.-\",\"upload_erpnext_items\":1,\"update_shopify_item_on_update\":1,\"warehouse\":\"Lagerräume - LIQ\",\"update_erpnext_stock_levels_to_shopify\":1,\"inventory_sync_frequency\":\"15\",\"sync_old_orders\":0,\"is_old_data_migrated\":0,\"last_inventory_sync\":\"2022-04-08 15:37:08.622451\",\"doctype\":\"Shopify Setting\",\"webhooks\":[{\"name\":\"68df12f801\",\"owner\":\"oke.brandt@liquam.com\",\"creation\":\"2022-03-25 14:36:44.762213\",\"modified\":\"2022-04-04 11:06:08.135653\",\"modified_by\":\"oke.brandt@liquam.com\",\"parent\":\"Shopify Setting\",\"parentfield\":\"webhooks\",\"parenttype\":\"Shopify Setting\",\"idx\":1,\"docstatus\":0,\"webhook_id\":\"1132601114863\",\"method\":\"orders/create\",\"doctype\":\"Shopify Webhooks\"},{\"name\":\"4a2efebc3f\",\"owner\":\"oke.brandt@liquam.com\",\"creation\":\"2022-03-25 14:36:44.763735\",\"modified\":\"2022-04-04 11:06:08.135653\",\"modified_by\":\"oke.brandt@liquam.com\",\"parent\":\"Shopify Setting\",\"parentfield\":\"webhooks\",\"parenttype\":\"Shopify Setting\",\"idx\":2,\"docstatus\":0,\"webhook_id\":\"1132601147631\",\"method\":\"orders/paid\",\"doctype\":\"Shopify Webhooks\"},{\"name\":\"3b1e601580\",\"owner\":\"oke.brandt@liquam.com\",\"creation\":\"2022-03-25 14:36:44.764359\",\"modified\":\"2022-04-04 11:06:08.135653\",\"modified_by\":\"oke.brandt@liquam.com\",\"parent\":\"Shopify Setting\",\"parentfield\":\"webhooks\",\"parenttype\":\"Shopify Setting\",\"idx\":3,\"docstatus\":0,\"webhook_id\":\"1132601180399\",\"method\":\"orders/fulfilled\",\"doctype\":\"Shopify Webhooks\"},{\"name\":\"f0ebcbecc2\",\"owner\":\"oke.brandt@liquam.com\",\"creation\":\"2022-03-25 14:36:44.764943\",\"modified\":\"2022-04-04 11:06:08.135653\",\"modified_by\":\"oke.brandt@liquam.com\",\"parent\":\"Shopify Setting\",\"parentfield\":\"webhooks\",\"parenttype\":\"Shopify Setting\",\"idx\":4,\"docstatus\":0,\"webhook_id\":\"1132601213167\",\"method\":\"orders/cancelled\",\"doctype\":\"Shopify Webhooks\"}],\"taxes\":[{\"name\":\"26ddf0e58c\",\"owner\":\"oke.brandt@liquam.com\",\"creation\":\"2022-03-25 14:36:22.793365\",\"modified\":\"2022-04-04 11:06:08.135653\",\"modified_by\":\"oke.brandt@liquam.com\",\"parent\":\"Shopify Setting\",\"parentfield\":\"taxes\",\"parenttype\":\"Shopify Setting\",\"idx\":1,\"docstatus\":0,\"shopify_tax\":\"Steuern Shopify\",\"tax_account\":\"Erlöse - LIQ\",\"doctype\":\"Shopify Tax Account\"}],\"shopify_warehouse_mapping\":[{\"name\":\"78ae0a4105\",\"owner\":\"oke.brandt@liquam.com\",\"creation\":\"2022-03-25 14:36:22.793365\",\"modified\":\"2022-04-04 11:06:08.135653\",\"modified_by\":\"oke.brandt@liquam.com\",\"parent\":\"Shopify Setting\",\"parentfield\":\"shopify_warehouse_mapping\",\"parenttype\":\"Shopify Setting\",\"idx\":1,\"docstatus\":0,\"shopify_location_id\":\"68238147823\",\"shopify_location_name\":\"Ramskamp 58b\",\"erpnext_warehouse\":\"Lagerräume - LIQ\",\"doctype\":\"Shopify Warehouse Mapping\"}],\"__last_sync_on\":\"2022-04-08T13:43:31.393Z\",\"__unsaved\":1}",
		"action": "Save"
	},
	"btn": {
		"jQuery2240096862547617124321": {
			"events": {
				"click": [
					{
						"type": "click",
						"origType": "click",
						"guid": 578,
						"namespace": ""
					}
				]
			}
		}
	},
	"freeze": true,
	"headers": {},
	"error_handlers": {},
	"url": "/api/method/frappe.desk.form.save.savedocs"
}

Response Data

{
	"exception": "UnicodeEncodeError: 'latin-1' codec can't encode characters in position 0-33: ordinal not in range(256)"
}

Can anyone help out here?