feat: ic-cdk and ic-cdk-macros v0.20.2 — interpret empty vector as candid encoding of () - #711
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR makes the ic-cdk entrypoint macros (update, query, init, post_upgrade) more permissive by treating an empty msg_arg_data() payload (vec![]) as the Candid “no-arguments” encoding, allowing methods with optional parameters to decode missing inputs as None.
Changes:
- Adjust macro-generated argument decoding to treat an empty input blob as Candid-encoded “no args” (
()), even when the method signature expects arguments. - Add end-to-end coverage to ensure
vec![]is accepted for methods takingOption<...>arguments (update + query). - Document the behavior change in the
ic-cdkchangelog.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
ic-cdk/CHANGELOG.md |
Documents the new empty-input decoding behavior for entry points. |
ic-cdk-macros/src/export.rs |
Implements the empty-input-as-() decoding behavior in macro output (and updates macro expansion tests). |
e2e-tests/tests/macros.rs |
Adds integration assertions that empty binary input is accepted for optional-arg methods. |
e2e-tests/src/bin/macros/main.rs |
Introduces foo_update / foo_query canister methods (with Option<u64> args) used by the new e2e test. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
mraszyk
marked this pull request as ready for review
June 8, 2026 15:14
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Decode the empty-input args from a &[u8] slice pointing at the static Candid header (DIDL\0\0) instead of allocating a Vec<u8> on every call with empty input. Addresses Copilot review feedback on #711. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
lwshang
approved these changes
Jun 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR fixes the CDK macros for update, query,
init, andpost_upgrademethods to interpret an empty input vector as the Candid encoding of()even if the method has a non-empty argument list. The motivation is to allow passing an empty input vector to method taking optional arguments and have them be decoded toNoneby default.This PR also releases ic-cdk and ic-cdk-macros v0.20.2 (version bumps in the workspace + crate manifests and the corresponding
ic-cdkCHANGELOG entry).How Has This Been Tested?
New integration tests have been introduced.
Checklist: