Repository navigation
fix: fall back on the public status for every access-denied reject - #743
Conversation
There was a problem hiding this comment.
Pull request overview
Extends canister-status access-denial handling so direct calls can fall back to public state-tree data.
Changes:
- Recognizes three access-denied codes and both reject forms.
- Adds unit and integration coverage.
- Updates documentation and changelog.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
crates/icp-cli/src/commands/canister/status.rs |
Expands reject handling and fallback logic. |
crates/icp-cli/tests/canister_status_tests.rs |
Tests denied-access fallback. |
docs/reference/cli.md |
Clarifies fallback behavior. |
CHANGELOG.md |
Documents the fix. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| let Some(reject) = direct_call_reject(&e) else { | ||
| bail!("Unknown error fetching canister {cid} status: {e}"); | ||
| }; |
There was a problem hiding this comment.
Intentional — --proxy shouldn't fall back.
The direct fallback earns its keep because the caller there is whatever identity happens to be selected, so a denial is usually a benign accident. --proxy <principal> is a deliberate claim that this canister can read the status; if it can't, that's a misconfiguration worth surfacing. --public already covers the state-tree view.
Classifying it would also mean changing the proxy interface: ProxyError::CallFailed { reason: String } flattens the reject to free text before the CLI sees it, so today it'd mean string-matching IC0542 inside reason.
`icp canister status` falls back on the state-tree information when the caller may not read the status, but keyed on the single error code `IC0512`. Replicas carrying status visibility reject the call with `IC0542` instead, so the command fails with `Error looking up canister <id>` rather than falling back. `IC0541`, returned on subnets with administrators, was never handled either. The fallback also matched only `AgentError::UncertifiedReject`. The replica checks access both when accepting the ingress message and again during execution, so the same denial can arrive certified, and that path bypassed the fallback entirely. Both are now matched, as `is_canister_not_found` and `is_serving_reject` already do elsewhere. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01QooMLZ15EWRrknWtXfFZNp
a4fb8d6 to
4028f36
Compare
What
icp canister statusfalls back on the publicly readable state-tree information — controllers and module hash — when the caller may not read the status. That fallback keyed on the single error codeIC0512.Replicas carrying the status-visibility feature reject the call with
IC0542(CanisterStatusAccessDenied) instead, so on today's mainnet the released CLI already fails withError looking up canister <id>rather than falling back.IC0541(CanisterInvalidControllerOrSubnetAdmin, returned on subnets with administrators) was never handled either. All three are now recognised.The fallback also matched only
AgentError::UncertifiedReject. The replica checks access twice — when accepting the ingress message, and again inget_canister_statusduring execution — so the same denial arrives uncertified from the first and certified from the second, and the certified path bypassed the fallback entirely. Both are now matched, asis_canister_not_foundandis_serving_rejectalready do elsewhere.The certified path is defensive rather than a reproduced failure: in practice the ingress filter catches the denial first and the reject arrives uncertified, which is what the new integration test observes. The same change also means a certified
IC0301now reports "Canister not found" instead of falling through to the generic error.Testing
canister_status_falls_back_when_access_is_denied— hands sole controllership to another identity and reads the status back. Against the pinned network launcher this fails onmainwith exactlyError looking up canister <id>: Some("IC0542") - Caller ... is not allowed to read the canister status.