Title: Returned error in result missing error subject (discovered in metafield create/update) · Issue #204 · Shopify/shopify_python_api · GitHub
Open Graph Title: Returned error in result missing error subject (discovered in metafield create/update) · Issue #204 · Shopify/shopify_python_api
X Title: Returned error in result missing error subject (discovered in metafield create/update) · Issue #204 · Shopify/shopify_python_api
Description: The shopify API returns the subject of an error as a key in the json error string, and pyactiveresource sometimes adds the value but not the key when it unpacks the string. This probably shows up for some errors generated when adding or ...
Open Graph Description: The shopify API returns the subject of an error as a key in the json error string, and pyactiveresource sometimes adds the value but not the key when it unpacks the string. This probably shows up f...
X Description: The shopify API returns the subject of an error as a key in the json error string, and pyactiveresource sometimes adds the value but not the key when it unpacks the string. This probably shows up f...
Opengraph URL: https://github.com/Shopify/shopify_python_api/issues/204
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Returned error in result missing error subject (discovered in metafield create/update)","articleBody":"The shopify API returns the subject of an error as a key in the json error string, and pyactiveresource sometimes adds the value but not the key when it unpacks the string.\r\n\r\nThis probably shows up for some errors generated when adding or modifying variants or metafields, as they show up as lists of hashes in the object attributes. I hit a problem when adding or updating a metafield on a variant, and decided to dig.\r\n\r\nThe issue is in class Errors in activeresource.py:\r\n\r\n\u003cpre\u003e\r\n def from_hash(self, messages):\r\n attribute_keys = self.base.attributes.keys()\r\n for key, errors in six.iteritems(messages):\r\n for message in errors:\r\n if key in attribute_keys:\r\n self.add(key, message)\r\n else:\r\n self.add_to_base(message)\r\n\u003c/pre\u003e\r\n\r\nAn error return like this:\r\n\r\n\u003cpre\u003e\r\n{\r\n \"errors\": {\r\n \"metafields.namespace\": [\"can't be blank\", \"is too short (minimum is 3 characters)\"]\r\n }\r\n}\r\n\u003c/pre\u003e\r\n\r\n(caused by trying to create or update a metafield with the key \"name-space\" instead of \"namespace\" :) will lose the important tidbit, the field causing the issue: \"metafields\" is a key in the variant attributes, but \"metafields.namespace\" is not.\r\n\r\nPerhaps this might be a more robust approach?\r\n\r\n\u003cpre\u003e\r\n def from_hash(self, messages):\r\n attribute_keys = self.base.attributes.keys()\r\n for key, errors in six.iteritems(messages):\r\n for message in errors:\r\n if key.split('.')[0] in attribute_keys:\r\n self.add(key, message)\r\n else:\r\n self.add_to_base(' '.join([key, message]))\r\n\u003c/pre\u003e\r\n\r\nThanks!\r\n\r\nRick\r\n\r\n\r\n ","author":{"url":"https://github.com/rlevine","@type":"Person","name":"rlevine"},"datePublished":"2017-07-12T17:04:15.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/204/shopify_python_api/issues/204"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:a794ac43-444a-9947-487f-1e2aa3adae1d |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A502:12F8:25C1689:34A2CE0:6969440D |
| html-safe-nonce | 76ad9827f93781e4cb0f18946b8ef7b51925e4b902c1b231904166685c80bb10 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNTAyOjEyRjg6MjVDMTY4OTozNEEyQ0UwOjY5Njk0NDBEIiwidmlzaXRvcl9pZCI6IjI2NDIzNTc4NjkwMzcwNDQ3NDkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 94abeebd10a84ff4985e19732450cf273790cd65691a8fca06327e592e3e3f9a |
| hovercard-subject-tag | issue:242450561 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/Shopify/shopify_python_api/204/issue_layout |
| twitter:image | https://avatars.githubusercontent.com/u/8085?s=400&v=4 |
| twitter:card | summary |
| og:image | https://avatars.githubusercontent.com/u/8085?s=400&v=4 |
| og:image:alt | The shopify API returns the subject of an error as a key in the json error string, and pyactiveresource sometimes adds the value but not the key when it unpacks the string. This probably shows up f... |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | rlevine |
| hostname | github.com |
| expected-hostname | github.com |
| None | 54182691a21263b584d2e600b758e081b0ff1d10ffc0d2eefa51cf754b43b51d |
| turbo-cache-control | no-preview |
| go-import | github.com/Shopify/shopify_python_api git https://github.com/Shopify/shopify_python_api.git |
| octolytics-dimension-user_id | 8085 |
| octolytics-dimension-user_login | Shopify |
| octolytics-dimension-repository_id | 2249127 |
| octolytics-dimension-repository_nwo | Shopify/shopify_python_api |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 2249127 |
| octolytics-dimension-repository_network_root_nwo | Shopify/shopify_python_api |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | d69ac0477df0f87da03b8b06cebd187012d7a930 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width