Returned error in result missing error subject (discovered in metafield create/update)
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 2/5
- Temps estimé
- 1-3 heures
- Accessibilité débutants
- 35/100
Piste de recherche
Commencez dans activeresource.py, au niveau de la classe Errors et de sa méthode from_hash, puis examinez comment les clés d’erreur imbriquées sont dépaquetées. Reproduisez le cas metafield-on-variant en utilisant la réponse metafields.namespace indiquée. C’est terminé lorsque l’erreur renvoyée conserve la clé subject au lieu de perdre le champ à l’origine de l’erreur.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
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 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
- Langage dominant
- Python
- Étoiles
- 1.4k
- Forks
- 388
- Merge moyen
- 5 h 39 min
- PR mergées (30 j)
- 1
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de Shopify/shopify_python_api
-
automated
Difficulté 3/5 1-2 jours Accessibilité débutants 68/100
Shopify/shopify_python_api#799 ·
-
automated Stale
Difficulté 4/5 3-5 jours Accessibilité débutants 35/100
Shopify/shopify_python_api#796 · 2 commentaires ·
-
automated
Difficulté 4/5 3-5 jours Accessibilité débutants 35/100
Shopify/shopify_python_api#792 ·
-
Account Activation URL Ouvertefeature request
Difficulté 2/5 1-3 heures Accessibilité débutants 45/100
Shopify/shopify_python_api#275 · 4 commentaires ·
-
feature request
Difficulté 2/5 1-3 heures Accessibilité débutants 38/100
Shopify/shopify_python_api#233 ·
Toutes les issues de Shopify/shopify_python_api
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
anthropics/skills#1811 · 1 commentaire ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
speaches-ai/speaches#678 ·
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
datalayer/mcp-compose#42 ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
conda-forge/spacy-feedstock#177 ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
UKGovernmentBEIS/inspect_evals#2523 ·