Returned error in result missing error subject (discovered in metafield create/update)
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 35/100
Direzione di ricerca
Inizia in activeresource.py, nella classe Errors e nel suo metodo from_hash, quindi esamina come vengono spacchettate le chiavi di errore annidate. Riproduci il caso metafield-on-variant usando la risposta metafields.namespace mostrata. Il lavoro è completato quando l'errore restituito conserva la chiave subject invece di perdere il campo che causa l'errore.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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
- Lingua principale
- Python
- Stelle
- 1.4k
- Fork
- 388
- Merge medio
- 5h 39m
- PR unite (30g)
- 1
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di Shopify/shopify_python_api
-
automated
Difficoltà 3/5 1-2 giorni Idoneità per principianti 68/100
Shopify/shopify_python_api#799 ·
-
automated Stale
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
Shopify/shopify_python_api#796 · 2 commenti ·
-
automated
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
Shopify/shopify_python_api#792 ·
-
Account Activation URL Apertafeature request
Difficoltà 2/5 1-3 ore Idoneità per principianti 45/100
Shopify/shopify_python_api#275 · 4 commenti ·
-
feature request
Difficoltà 2/5 1-3 ore Idoneità per principianti 38/100
Shopify/shopify_python_api#233 ·
Tutte le issue di Shopify/shopify_python_api
Issue simili
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
canonical/paas-charm#368 · 1 commento ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
tech debt
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
addition to tracking list Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
StevenBlack/hosts#3256 ·
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
qualcomm/qai-appbuilder#275 ·