Returned error in result missing error subject (discovered in metafield create/update)
還沒有人認領這個 Issue。
評估
研究方向
從 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 分鐘
- 30 天內合併 PR
- 1
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
Shopify/shopify_python_api 的其他 Issue
-
automated
難度 3/5 1-2 天 新手友好度 68/100
Shopify/shopify_python_api#799 ·
-
automated
難度 4/5 3-5 天 新手友好度 35/100
Shopify/shopify_python_api#796 · 1 則留言 ·
-
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
-
難度 1/5 1 小時以內 新手友好度 90/100
-
bug
難度 2/5 1-3 小時 新手友好度 86/100
zostera/django-bootstrap4#894 ·
-
難度 2/5 1-3 小時 新手友好度 78/100
use-agent-os/agent-os#3276 ·
-
難度 2/5 1-3 小時 新手友好度 88/100
zephyrproject-rtos/zephyr#119726 ·
-
area/auth bug comp/agent P3 platform/discord type/security
難度 2/5 1-3 小時 新手友好度 88/100
NousResearch/hermes-agent#117848 ·