Skip to content

Commit a9716f1

Browse files
lwshangclaude
andcommitted
fix: warn on effective controller removal in canister settings update
When --proxy is set, the proxy canister is the effective controller making management calls. The self-removal warning now checks the proxy principal instead of the caller's identity, preventing false prompts (and "not a terminal" errors in tests) when adding controllers to proxy-deployed canisters. Warning messages are also updated to be accurate for each case. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 8f17032 commit a9716f1

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

crates/icp-cli/src/commands/canister/settings/update.rs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,13 +191,25 @@ pub(crate) async fn exec(ctx: &Context, args: &UpdateArgs) -> Result<(), anyhow:
191191
if let Some(controllers_opt) = &args.controllers {
192192
controllers = get_controllers(controllers_opt, current_status.as_ref());
193193

194-
// Check if the caller is being removed from controllers
194+
// Check if the effective controller is being removed from the controller list.
195+
// When --proxy is set, the proxy canister is the one making management calls and
196+
// is the effective controller. Without --proxy, it's the caller's identity.
197+
let effective_controller = args.proxy.unwrap_or(caller_principal);
195198
if let Some(new_controllers) = &controllers
196-
&& !new_controllers.contains(&caller_principal)
199+
&& !new_controllers.contains(&effective_controller)
197200
&& !args.force
198201
{
199-
warn!("You are about to remove yourself from the controllers list.");
200-
warn!("This will cause you to lose control of the canister and cannot be undone.");
202+
if args.proxy.is_some() {
203+
warn!(
204+
"You are about to remove the proxy canister ({effective_controller}) from the controllers list."
205+
);
206+
warn!(
207+
"This will prevent further management calls through this proxy and cannot be undone."
208+
);
209+
} else {
210+
warn!("You are about to remove yourself from the controllers list.");
211+
warn!("This will cause you to lose control of the canister and cannot be undone.");
212+
}
201213

202214
let confirmed = Confirm::new()
203215
.with_prompt("Do you want to proceed?")

crates/icp-cli/tests/canister_settings_tests.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,8 @@ async fn canister_settings_update_through_proxy() {
389389
"my-canister",
390390
"--environment",
391391
"random-environment",
392+
"--proxy",
393+
&proxy_cid,
392394
])
393395
.assert()
394396
.success()
@@ -1459,6 +1461,8 @@ async fn canister_settings_sync_through_proxy() {
14591461
"my-canister",
14601462
"--environment",
14611463
"random-environment",
1464+
"--proxy",
1465+
&proxy_cid,
14621466
])
14631467
.assert()
14641468
.success()

0 commit comments

Comments
 (0)