icp-cli: bindgen record fields with opt are undefined when empty, not null
Maintainer thường phản hồi trong vòng 6 ngày
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
- 78/100
- Loại issue
- Tài liệu
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- typescript
- Lĩnh vực
- documentation, testing
Hướng nghiên cứu
Đọc skills/icp-cli/references/binding-generation.md:67-69 và eval hiện có tên là “Candid opt T representation in bindgen”. Cập nhật tài liệu để phân biệt các giá trị opt đơn thuần với các trường record tùy chọn, khuyến nghị cách kiểm tra giá trị rỗng không phụ thuộc phiên bản và thêm một eval cho trường hợp trường record. Công việc hoàn tất khi mapping đã chỉnh sửa được ghi lại trong tài liệu và eval mới chạy thành công.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
skills/icp-cli/references/binding-generation.md:67-69 says bindgen's wrapper turns opt T into T | null and tells agents to "always use T | null". That holds for a plain opt, but not for a record field: an opt T field is an optional property that is undefined when empty. An agent following the rule writes if (r.value !== null), which is true for an empty field. The certified-variables helper had exactly this bug: it rejected a valid proof of absence (fixed in #407).
Verified against the @icp-sdk/bindgen 0.4.0 and 0.4.1 wrappers:
| Candid position | Wrapper type | Empty value |
|---|---|---|
argument, return value, vec element, variant payload: opt T |
T | null |
null |
record field f : opt T |
f?: T |
undefined (field omitted) |
nested opt opt T (not in a record) |
Some<T | null> | None |
None |
Needed regardless of the bindgen PRs
These hold on 0.4.1 and after dfinity/icp-js-bindgen#197, dfinity/icp-js-bindgen#198 and dfinity/icp-js-bindgen#201:
- Correct the section in
binding-generation.md.T | nullapplies to a plainopt. A record field is optional andundefinedwhen empty. To send an absent field, omit it or passundefined. - Recommend
== nullor??for "is it empty". It is correct in every position and version, so an agent doesn't need to know which position it is in. - Add an eval for the record-field case. The existing case ("Candid opt T representation in bindgen") covers only a plain return value, and its expected
result !== nullstays correct. - Fix it in place, in
icp-cli. #406 movesbinding-generation.md'soptsection intocanister-callslater; the move then carries the corrected text. #406's own Candid↔TS table had the same gap (opt T→T | nullonly) and is corrected there, since it is the long-term home of the full mapping.
After the bindgen fixes are released
-
dfinity/icp-js-bindgen#197 (present but falsy optionals): until it ships,
0,falseand""in an optional record field or variant payload are sent as absent. No skill change is needed once it ships. If it is skipped, add a pitfall: send such values only in a plainoptargument, or avoid falsy values in optional fields. -
dfinity/icp-js-bindgen#198 (
opt optrecord fields): once released, documentf?: T | nullwith its three states (omitted,nullforopt null, a value), pinned to that bindgen version. If it is skipped, the skill must say instead thatopt optrecord fields do not match their declared type (they decode toSome/Noneobjects, andnullcannot be sent), and point to the raw declarations for those fields. -
dfinity/icp-js-bindgen#201 (actor class name): once released, generating the actor files for a
.didfile named after one of its own types (governance.didwithtype Governance,swap.didwithtype Swap) fails with a hint to rename the file. Where the skill shows vendoring NNS or SNS interfaces, if anywhere, use a distinct file name (e.g.nns_governance.did). The same advice applies if it is skipped, since the class then merges with the type without an error. -
dfinity/icp-js-bindgen#203 (docs for
--actor-interface-file): no skill change. It documents the.d.tsas a reference that leaves out the actor class, which is howcaffeine-app(--actor-interface-file) andwriting-motoko("use the generatedbackend.d.tsas the source of truth") already use it; neither imports it. -
dfinity/icp-js-bindgen#172 (proposed, no PR yet): if adopted, an inline unit variant becomes a string-literal union instead of a
Variant_<tags>or borrowed enum. No skill referencesVariant_<tags>today, so nothing breaks; the mapping in #406 then gains that row.
Until the bindgen PRs are decided, document only the first section.
- Ngôn ngữ chính
- Python
- Star
- 39
- Fork
- 19
- Merge trung bình
- 5 ngày 3 giờ
- Pull request đã merge (30 ngày)
- 19
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc 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 dfinity/icskills
-
generated hallucination skill-improvement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 90/100
Maintainer thường phản hồi trong vòng 6 ngày
-
Version drift: mo:core pinned at 2.0.0 / 2.3.1 / 2.5.0 across skillsCó thể đã có người làm @raymondk đã nhận 95 ngày trước. Đang mởgenerated
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 6 ngày
-
generated
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 78/100
dfinity/icskills#292 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 6 ngày
-
generated
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 72/100
dfinity/icskills#291 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 6 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
Maintainer thường phản hồi trong vòng 6 ngày
Tất cả issue của dfinity/icskills
Issue tương tự
-
Djangonauts
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
render-engine/render-engine-cli#71 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Installation guide's prerequisites leave out ca-certificates, which a no-recommends system needsĐang mởbot-found documentation priority: P3
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 94/100
madenvel/KalinkaPlayer#544 ·
-
debt python-version
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
microsoft/vscode-flake8#614 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 69/100
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 2 ngày