Returned error in result missing error subject (discovered in metafield create/update)
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Anfängerfreundlichkeit
- 35/100
Rechercherichtung
Beginne in activeresource.py bei der Klasse Errors und ihrer from_hash-Methode, und untersuche dann, wie verschachtelte Fehlerschlüssel entpackt werden. Reproduziere den Fall metafield-on-variant mit der gezeigten metafields.namespace-Antwort. Fertig ist es, wenn der zurückgegebene Fehler den subject-Schlüssel beibehält, anstatt das Feld zu verlieren, das den Fehler verursacht.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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
- Vorherrschende Sprache
- Python
- Sterne
- 1.4k
- Forks
- 388
- Ø Merge
- 5 Std. 39 Min.
- Gemergte PRs (30 T.)
- 1
Beitragsleitfaden
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus Shopify/shopify_python_api
-
automated
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 68/100
Shopify/shopify_python_api#799 ·
-
automated
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 35/100
Shopify/shopify_python_api#796 · 1 Kommentar ·
-
automated
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 35/100
Shopify/shopify_python_api#792 ·
-
Account Activation URL Offenfeature request
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 45/100
Shopify/shopify_python_api#275 · 4 Kommentare ·
-
feature request
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 38/100
Shopify/shopify_python_api#233 ·
Alle Issues in Shopify/shopify_python_api
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
qgis/QGIS-Documentation#11275 ·
-
bug priority:normal ready-for-dev
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
OpenHands/extensions#626 · 1 Kommentar ·
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 90/100
CSCfi/sd-search-api#39 ·
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 90/100
-
please add to porn list Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
StevenBlack/hosts#3255 ·