dfx warns about a breaking change when adding a new tag to an optional variant field.
However, such a change should be considered backwards compatible according to the spec and Roman’s guide.
To make it concrete. Let’s say we have this candid interface:
type Token = variant {
ICP;
USDC
};
type Asset = record {
token : opt Token
};
service : {
"go" : (Asset) -> (Asset) query
}
If we try to upgrade to a new interface with a new token:
type Token = variant {
ICP;
USDC;
USDT
};
type Asset = record {
token : opt Token
};
service : {
"go" : (Asset) -> (Asset) query
}
Then dfx 0.27.0
shows the following warning:
WARNING!
Candid interface compatibility check failed for canister 'check_candid_backend'.
You are making a BREAKING change. Other canisters or frontend clients relying on your canister may stop working.
Method go: func (Asset) -> (Asset) query is not a subtype of func (Asset/1) -> (Asset/1) query
Do you want to proceed? yes/No
I checked that both rust and js can safely handle the change and decode a new token
as null
(confirmed what the spec says).