Repository navigation
fix(pic): read HTTPS outcalls made with PUT, DELETE and PATCH - #320
Conversation
PocketIC reports a pending HTTPS outcall's method as GET, POST, HEAD, PUT, DELETE or PATCH, but getPendingHttpsOutcalls only decoded the first three and threw "Unknown canister HTTP method" for the rest. A test of a canister that sends a PUT, DELETE or PATCH request could not answer it. The test canister gains a method that makes a non-replicated outcall with a given method (the IC allows PUT, DELETE and PATCH only there). The new test reads and answers one outcall per method; before the fix, the PUT, DELETE and PATCH cases failed with the decode error. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Dear @alexandru-uta, In order to potentially merge your code in this open-source repository and therefore proceed with your contribution, we need to have your approval on DFINITY's CLA. If you decide to agree with it, please visit this issue and read the instructions there. Once you have signed it, re-trigger the workflow on this PR to see if your code can be merged. — The DFINITY Foundation |
There was a problem hiding this comment.
🟢 Approval recommended
The method enums, decoder, and test-canister interfaces are consistent, with regression coverage for all six methods and no unresolved findings.
No open issues 🎉
What changed in this PR
This PR fixes PocketIC’s pending HTTPS outcall decoding so tests can read and answer PUT, DELETE, and PATCH requests alongside GET, POST, and HEAD.
Changes:
- Extends public and client method enums and decoding to support all six methods.
- Adds a test-canister endpoint for non-replicated HTTPS outcalls.
- Adds regression tests that read and answer an outcall for each method.
| File | Description |
|---|---|
packages/pic/tests/test-canister/test_canister.did |
Declares the HTTP method variant and test endpoint. |
packages/pic/tests/test-canister/main.mo |
Implements non-replicated outcalls with a selected method. |
packages/pic/tests/test-canister/declarations/test_canister.did.js |
Adds Candid bindings for the endpoint. |
packages/pic/tests/test-canister/declarations/test_canister.did.d.ts |
Adds TypeScript types for the endpoint. |
packages/pic/tests/src/https-outcalls.spec.ts |
Tests decoding and responding to all six methods. |
packages/pic/src/pocket-ic-types.ts |
Extends the public HTTP method enum. |
packages/pic/src/pocket-ic-client-types.ts |
Extends client enums and method decoding. |
Review effort: Balanced
|
Dear @alexandru-uta, In order to potentially merge your code in this open-source repository and therefore proceed with your contribution, we need to have your approval on DFINITY's CLA. If you decide to agree with it, please visit this issue and read the instructions there. Once you have signed it, re-trigger the workflow on this PR to see if your code can be merged. — The DFINITY Foundation |
…ackport) (#322) Backport of #320 to the 0.23 release line, for a 0.23.1 patch release. PocketIC reports a pending HTTPS outcall's method as GET, POST, HEAD, PUT, DELETE or PATCH, but `getPendingHttpsOutcalls` only decoded the first three and threw `Unknown canister HTTP method: PUT` for the rest, so a test could not answer a canister's PUT, DELETE or PATCH request. `CanisterHttpMethod` and its decoder now cover all six methods; the API is otherwise unchanged from 0.23.0. The test canister gains `http_request_status`, which makes a non-replicated outcall with a given method (the IC allows PUT, DELETE and PATCH only there), and a new spec reads and answers one outcall per method. PocketIC 14, which this line pins, makes no PATCH outcalls, so the spec covers GET, HEAD, POST, PUT and DELETE; with the decoder change reverted, PUT and DELETE fail with the decode error. PATCH passes against PocketIC 15. 0.23.1 should be published under its own dist-tag so it does not replace 0.25.0 as `latest`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
PocketIC reports a pending HTTPS outcall's method as GET, POST, HEAD, PUT, DELETE or PATCH, but
getPendingHttpsOutcallsonly decoded the first three and threwUnknown canister HTTP method: PUTfor the rest, so a test could not answer a canister's PUT, DELETE or PATCH request.CanisterHttpMethodand its decoder now cover all six methods. The test canister gainshttp_request_status, which makes a non-replicated outcall with a given method (the IC allows PUT, DELETE and PATCH only there), and a new spec reads and answers one outcall per method. With the decoder change reverted, the PUT, DELETE and PATCH cases fail with the decode error.🤖 Generated with Claude Code