dfinity / dfinity/agent-rs

`ManagementCanister::delete_canister_snapshot` does not work for canisters on IC mainnet

Open
#642 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

triage
Dominant language
Rust
Stars
144
Forks
84
Avg merge
20h 4m
Merged PRs (30d)
1

Description

Given this code:

    let client = ManagementCanister::create(agent);

    client
        .delete_canister_snapshot(&canister, &snapshot_id.id)
        .await?;

When I run this code for any canister on the local dfx network, it does work, but when running for a canister on IC mainnet, an error is returned:

The replica returned an HTTP Error: Http Error: status 400 Bad Request, content type "text/plain; charset=utf-8", content: error: canister_not_found
details: The specified canister does not exist.

This code however works for both local and mainnet canisters:

    let call: AsyncCaller<'_, ()> = client.update(MgmtMethod::DeleteCanisterSnapshot.as_ref())
        .with_arg(In {
            canister_id: canister,
            snapshot_id: &snapshot_id.id,
        })
        .with_effective_canister_id(canister)
        .build();

    call.await?;

The difference with the delete_canister_snapshot() implementation is this line:

.with_effective_canister_id(canister)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the Rust implementation of ManagementCanister::delete_canister_snapshot and compare its request construction with the working AsyncCaller example in the issue. Verify the behavior against both a local dfx canister and an IC mainnet canister; done means the management call no longer returns canister_not_found on mainnet.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
api, distributed-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.