Sync actions fail with error on an undefined field
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- javascript, nodejs
Hướng nghiên cứu
Bắt đầu bằng cách tái hiện trường hợp đồng bộ hóa khách hàng và kiểm tra packages/data-import/dist/lib/sync.js cùng với các stack frame của sync-actions trong buildArrayActions và actionsMapAddresses. Hoàn tất có nghĩa là cùng payload đó không còn gây ra exception khi các thuộc tính như addresses hoặc shippingAddressIds là undefined, và các actions tạo ra tuân theo hành vi đã nêu là bỏ qua hoặc dùng một mảng rỗng.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Description
I was wondering what is expected behaviour from commercetools nodejs sdk perspective in the following scenario:
- Create a customer:
{
"key": "abc",
"email": "[email protected]",
"password": "password"
}
- Use sync actions using the same payload:
{
"key": "abc",
"email": "[email protected]",
"password": "password"
}
It fails with an error:
TypeError: Cannot read property '0' of undefined
at /node_modules/@commercetools/sync-actions/dist/sync-actions.cjs.js:496:73
at Array.forEach (<anonymous>)
at buildArrayActions (/node_modules/@commercetools/sync-actions/dist/sync-actions.cjs.js:484:31)
at actionsMapAddresses (/node_modules/@commercetools/sync-actions/dist/sync-actions.cjs.js:906:10)
at /node_modules/@commercetools/sync-actions/dist/sync-actions.cjs.js:951:14
at mapActionGroup (/node_modules/@commercetools/sync-actions/dist/sync-actions.cjs.js:264:51)
at doMapActions (/node_modules/@commercetools/sync-actions/dist/sync-actions.cjs.js:950:21)
at Object.buildActions (/node_modules/@commercetools/sync-actions/dist/sync-actions.cjs.js:250:12)
at /packages/data-import/dist/lib/sync.js:37:33
at processTicksAndRejections (internal/process/task_queues.js:97:5)
It looks like sync actions fail to merge arrays when the new resource does not have a property defined. In the case of the customer type when a customer is created following properties are defined with empty array addresses, shippingAddressIds, billingAddressIds and stores.
Expected Behavior
Sync actions to skip a property for new resource when old resource has empty array and the property is not defined.
Alternatively, add the property with empty array which enables sync actions to resolve actions accordingly. (probably easier)
Current Behavior
Throws an error.
Possible Solution
I'm happy to create PR if that is expected behaviour.
- Ngôn ngữ chính
- JavaScript
- Star
- 77
- Fork
- 70
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
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 commercetools/nodejs
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 35/100
commercetools/nodejs#1901 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 45/100
commercetools/nodejs#1895 · 1 bình luận ·
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 55/100
commercetools/nodejs#1891 ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 20/100
commercetools/nodejs#1889 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
commercetools/nodejs#1884 · 4 reaction ·
Tất cả issue của commercetools/nodejs
Issue tương tự
-
factory-active factory-automatic harness/codex task-bug-reproduction-success task-identify-harness-labels-done task-identify-issue-type-done
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
vercel/ai#21582 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
ux
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
rr-djk/rr-djuikoo.com#53 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Add shacl12-inference-rulesĐang mởnew spec review
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
w3c/browser-specs#2666 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
thim81/openapi-format#238 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
decentespresso/dye2#13 ·