Skip to content

docs: fix HTTP gateway streaming callback return type#296

Merged
lwshang merged 1 commit into
mainfrom
docs/http-gateway-streaming-callback-fix
Jun 17, 2026
Merged

docs: fix HTTP gateway streaming callback return type#296
lwshang merged 1 commit into
mainfrom
docs/http-gateway-streaming-callback-fix

Conversation

@lwshang

@lwshang lwshang commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Summary

The streaming callback in the HTTP gateway protocol spec must return a non-opt StreamingCallbackHttpResponse. The spec incorrectly wrapped the return type in opt, which no real gateway accepts — candid cannot coerce wire-type opt T into the expected T, so serving any multi-chunk (streamed) asset fails to decode.

Fixed all three occurrences:

  • public/references/http-gateway.did (downloadable interface)
  • docs/references/http-gateway-protocol-spec.md — full Canister HTTP Interface block
  • docs/references/http-gateway-protocol-spec.md — Response Body Streaming Interface block
- callback: func (StreamingToken) -> (opt StreamingCallbackHttpResponse) query;
+ callback: func (StreamingToken) -> (StreamingCallbackHttpResponse) query;

Note: only the callback's return type changes. The token : opt Token field inside StreamingCallbackHttpResponse stays optional — a null token (not a null response) terminates the stream.

Verification

The real gateway decodes the callback reply into a non-opt StreamingCallbackHttpResponse:

ic-gatewayic-http-gateway-protocol (tag v0.5.1) → ic-agent / ic-utils

Detected while adding e2e streaming tests for certified-assets (dfinity/certified-assets#96). npm run build passes.

The streaming callback must return a non-opt StreamingCallbackHttpResponse,
matching the real HTTP gateway (ic_boundary) implementation. The spec
incorrectly wrapped the return type in opt.

Confirmed by the StreamingCallbackFunction definition in dfinity/internet-identity
and every shipping .did interface. Detected while adding e2e tests for
streaming certified-assets (dfinity/certified-assets#96).
@lwshang lwshang requested review from a team as code owners June 16, 2026 19:26
@github-actions github-actions Bot added the interface-spec Changes to the IC interface specification label Jun 16, 2026
@lwshang lwshang merged commit d6bab56 into main Jun 17, 2026
12 checks passed
@lwshang lwshang deleted the docs/http-gateway-streaming-callback-fix branch June 17, 2026 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

interface-spec Changes to the IC interface specification

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants