Skip to content

fix(cycles): icp cycles buy says when --gateway is not a canister or not a gateway - #827

Merged
raymondk merged 1 commit into
cycles-buy/02-arg-groupfrom
cycles-buy/03-gateway
Oct 20, 2026
Merged

raymondk merged 1 commit into
cycles-buy/02-arg-groupfrom
cycles-buy/03-gateway

Conversation

@raymondk

Copy link
Copy Markdown
Collaborator

Three things a user saw raw before, from #824 (commit 18f7794, gateway part), code by Josh:

  • a --gateway that cannot be a canister (anonymous principal, management canister, an identity's principal) is refused before any network is asked (NotACanister);
  • a canister that serves no get_card_terms is said to be no gateway (NotAGateway), where the user saw the replica's raw IC0536 "has no query method";
  • a boundary node's HTTP 4xx canister_not_found reads as the gateway being absent, as a replica's IC0301 does.

Names is how the command's prose names the gateway: CyclePay, and Stripe's page, only for CyclePay's own gateway; "the gateway" and "the gateway's payment page" for any other. Later PRs in the stack reuse it.

Not included from the source commit: the -n local-outside-a-project message, the MAINNET_HINT rewording and the 80-column message wrapping.

Tests: three unit tests in cyclepay/tests.rs, another_gateway_is_not_called_cyclepay, and the pocket-ic integration tests cycles_buy_refuses_a_gateway_that_cannot_be_one and cycles_buy_names_a_canister_that_is_no_gateway.


Part of restacking #824 into small PRs, one fix each, stacked on main in this order: cycles-buy/01-json-implies-yes → 02-arg-group → 03-gateway → 04-qr-colours → 05-paste-flags → then the wait, its follow-up text and the --json fields. Each PR targets the one below it; after the one below merges, retarget to main.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Twxau844tMTwyHpQJEbmBo

@raymondk
raymondk requested a review from a team as a code owner October 16, 2026 22:44
@lwshang
lwshang requested a balanced review from Copilot October 19, 2026 08:25

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.

🟢 Approval recommended

The focused changes and regression coverage reveal no blocking issues; tests were inspected but not executed.

No open issues 🎉

What changed in this PR

Improves icp cycles buy gateway diagnostics and avoids naming CyclePay or Stripe when using another gateway.

Changes:

  • Rejects invalid gateway principals before network access.
  • Clarifies missing-canister and missing-gateway-method errors.
  • Updates gateway-specific wording, regression tests, and documentation.
File Description
docs/​guides/​tokens-and-cycles.md Updates the confirmation example.
crates/​icp-cli/​tests/​cycles_tests.rs Tests gateway errors and generic delivery wording.
crates/​icp-cli/​src/​cyclepay/​tests.rs Tests principal validation and error mapping.
crates/​icp-cli/​src/​cyclepay/​purchase.rs Validates gateway IDs and translates network errors.
crates/​icp-cli/​src/​commands/​cycles/​buy.rs Applies validation and gateway-specific names.
CHANGELOG.md Records diagnostic and wording improvements.

Review effort: Balanced

@raymondk
raymondk added this pull request to stack #835 October 20, 2026 15:44
@raymondk
raymondk force-pushed the cycles-buy/03-gateway branch from 27d1a07 to 3ddc902 Compare October 20, 2026 15:45
…not a gateway

A --gateway that cannot be a canister (the anonymous principal, the
management canister, an identity's principal) is refused before any
network is asked; a canister that serves no get_card_terms is said to
be no gateway, where the user saw the replica's raw IC0536 "has no
query method" rejection; and a boundary node's HTTP 4xx
canister_not_found reads as the gateway being absent, as a replica's
IC0301 does, where the user saw the HTTP routing error.

Names, in buy.rs, is how the command's prose names the gateway:
CyclePay, and Stripe's page, for CyclePay's own gateway; "the gateway"
and "the gateway's payment page" for any other.

Extracted from PR #824.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Twxau844tMTwyHpQJEbmBo
@raymondk
raymondk force-pushed the cycles-buy/03-gateway branch from 3ddc902 to b41280b Compare October 20, 2026 17:45
@raymondk
raymondk merged commit b08fba4 into main Oct 20, 2026
106 checks passed
@raymondk
raymondk deleted the cycles-buy/03-gateway branch October 20, 2026 18:48
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.

4 participants