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
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 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.
The issue is in class Errors in activeresource.py:
def from_hash(self, messages):
attribute_keys = self.base.attributes.keys()
for key, errors in six.iteritems(messages):
for message in errors:
if key in attribute_keys:
self.add(key, message)
else:
self.add_to_base(message)
An error return like this:
{
"errors": {
"metafields.namespace": ["can't be blank", "is too short (minimum is 3 characters)"]
}
}
(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.
Perhaps this might be a more robust approach?
def from_hash(self, messages):
attribute_keys = self.base.attributes.keys()
for key, errors in six.iteritems(messages):
for message in errors:
if key.split('.')[0] in attribute_keys:
self.add(key, message)
else:
self.add_to_base(' '.join([key, message]))
Thanks!
Rick
The text was updated successfully, but these errors were encountered:
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 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.
The issue is in class Errors in activeresource.py:
An error return like this:
(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.
Perhaps this might be a more robust approach?
Thanks!
Rick
The text was updated successfully, but these errors were encountered: