Returned error in result missing error subject (discovered in metafield create/update)
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
Bắt đầu trong activeresource.py, tại class Errors và phương thức from_hash của nó, sau đó kiểm tra cách các khóa lỗi lồng nhau được giải nén. Tái hiện trường hợp metafield-on-variant bằng response metafields.namespace được hiển thị. Hoàn thành khi lỗi được trả về vẫn giữ khóa subject thay vì làm mất trường gây ra lỗi.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
- Ngôn ngữ chính
- Python
- Star
- 1.4k
- Fork
- 388
- Merge trung bình
- 5 giờ 39 phút
- Pull request đã merge (30 ngày)
- 1
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của Shopify/shopify_python_api
-
automated
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
Shopify/shopify_python_api#799 ·
-
automated
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
Shopify/shopify_python_api#796 · 1 bình luận ·
-
automated
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
Shopify/shopify_python_api#792 ·
-
Account Activation URL Đang mởfeature request
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 45/100
Shopify/shopify_python_api#275 · 4 bình luận ·
-
feature request
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 38/100
Shopify/shopify_python_api#233 ·
Tất cả issue của Shopify/shopify_python_api
Issue tương tự
-
area/auth bug comp/agent P3 platform/discord type/security
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
NousResearch/hermes-agent#117848 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
bancolombia/sentinel#23 ·
-
test md Đang mởCI
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
langchain-ai/deepagents#6450 ·
-
bug client
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100