Returned error in result missing error subject (discovered in metafield create/update)
まだ誰も着手していません。
評価
調査の方向性
activeresource.py の Errors クラスとその from_hash メソッドから始め、次にネストされたエラーキーがどのように展開されるかを調べます。示されている metafields.namespace レスポンスを使って、metafield-on-variant のケースを再現します。返されたエラーが subject キーを保持し、エラーの原因となっているフィールドを失わなければ完了です。
索引モデルが issue の本文から書いたものです。
説明
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
- 主要言語
- Python
- スター
- 1.4k
- フォーク
- 388
- 平均マージ
- 5時間 39分
- マージ済み PR(30日)
- 1
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
Shopify/shopify_python_api のほかの issue
-
automated
難易度 3/5 1〜2日 初心者へのやさしさ 68/100
Shopify/shopify_python_api#799 ·
-
automated Stale
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
Shopify/shopify_python_api#796 · コメント 2 件 ·
-
automated
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
Shopify/shopify_python_api#792 ·
-
feature request
難易度 2/5 1〜3時間 初心者へのやさしさ 45/100
Shopify/shopify_python_api#275 · コメント 4 件 ·
-
feature request
難易度 2/5 1〜3時間 初心者へのやさしさ 38/100
Shopify/shopify_python_api#233 ·
Shopify/shopify_python_api の issue をすべて見る
似ている issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 90/100
learningequality/ricecooker#747 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
BSData/horus-heresy-3rd-edition#3171 ·
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
run-llama/llama_index#23199 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
KhronosGroup/glTF-Blender-IO#2769 ·