sgqlc: http request encoding fails for some emoijs / UTF characters

Hello,

we use the your library to interact with Shopify’s API, which works great in general. Thanks for your effort to create and maintain it!

One of our use cases is to let our customers to customise products for them, we end up having a lot of emojis in the queries. Same of them cause encoding Exceptions. Like this here: 😍

POSTing it causes following error message:

2021-05-31 12:07:49,203 - ERROR - Process_28636 - MainThread - sgqlc.endpoint.http - GraphQL query failed with 1 errors
2021-05-31 12:07:49,205 - INFO - Process_28636 - MainThread - sgqlc.endpoint.http - Error #0:
2021-05-31 12:07:49,209 - INFO - Process_28636 - MainThread - sgqlc.endpoint.http -    | Parse error on bad Unicode escape sequence: "{\"customization_attributes\": {\"Design Id\": \"roadbik3-0073-a--nt\", \"_personalized\": \"true\", \"_personalized_value\": {\"dein Wunschtext\": \"Gravelbike \xED\xA0\xBD\xED\xB8\x8D\"}, \"dein Wunschtext\": \"Gravelbike \xED\xA0\xBD\xED\xB8\x8D\", \"Preview\": \"XXX\", \"_design_Preview\": \"XXX\", \"_pplr_preview\": \"Preview\"}}" (error) at [2, 229]
2021-05-31 12:07:49,213 - INFO - Process_28636 - MainThread - sgqlc.endpoint.http -    -
2021-05-31 12:07:49,217 - INFO - Process_28636 - MainThread - sgqlc.endpoint.http -    | Locations:
2021-05-31 12:07:49,222 - INFO - Process_28636 - MainThread - sgqlc.endpoint.http -    |  0 | mutation OrderAddMetafield {
2021-05-31 12:07:49,224 - INFO - Process_28636 - MainThread - sgqlc.endpoint.http -    |  1 | orderUpdate(input: {id: "gid://shopify/Order/XXXXXXXXXXXXX", metafields: [{description: "Customization data for LineItem(xxxxxxxxxxxxx) of Order(XXXXXXXXXXXXX).", key: "li_cust_xxxxxxxxxxxxx", namespace: "xxxxx_cstmzng", value: "{\"customization_attributes\": {\"Design Id\": \"roadbik3-0073-a--nt\", \"_personalized\": \"true\", \"_personalized_value\": {\"dein Wunschtext\": \"Gravelbike \\ud83d\\ude0d\"}, \"dein Wunschtext\": \"Gravelbike \\ud83d\\ude0d\", \"Preview\": \"xxxx\", \"_design_Preview\": \"xxxx\", \"_pplr_preview\": \"Preview\"}}", valueType: JSON_STRING}]}) {
2021-05-31 12:07:49,227 - INFO - Process_28636 - MainThread - sgqlc.endpoint.http -    |      ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------^

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 17 (10 by maintainers)

Most upvoted comments

Sorry for not delivering the Shopify examples. Live happened. 😃

Thanks for the fix!

done in v14