Skip to content

fix: fall back on the public status for every access-denied reject - #743

Merged
raymondk merged 1 commit into
mainfrom
rk/status-fallback-fix
Aug 28, 2026
Merged

raymondk merged 1 commit into
mainfrom
rk/status-fallback-fix

Conversation

@raymondk

Copy link
Copy Markdown
Collaborator

What

icp canister status falls 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 code IC0512.

Replicas carrying the status-visibility feature reject the call with IC0542 (CanisterStatusAccessDenied) instead, so on today's mainnet the released CLI already fails with Error 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 in get_canister_status during 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, as is_canister_not_found and is_serving_reject already 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 IC0301 now 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 on main with exactly Error looking up canister <id>: Some("IC0542") - Caller ... is not allowed to read the canister status.
  • One unit test pins that both reject forms are recognised and that a non-reject error still surfaces.

@raymondk
raymondk requested a review from a team as a code owner August 27, 2026 22:49
Copilot AI balanced review requested due to automatic review settings August 27, 2026 22:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +290 to +292
let Some(reject) = direct_call_reject(&e) else {
bail!("Unknown error fetching canister {cid} status: {e}");
};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
@raymondk
raymondk force-pushed the rk/status-fallback-fix branch from a4fb8d6 to 4028f36 Compare August 28, 2026 17:00
@raymondk
raymondk merged commit 042437a into main Aug 28, 2026
103 checks passed
@raymondk
raymondk deleted the rk/status-fallback-fix branch August 28, 2026 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants