docs: fix HTTP gateway streaming callback return type#296
Merged
Conversation
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).
marc0olo
approved these changes
Jun 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The streaming callback in the HTTP gateway protocol spec must return a non-opt
StreamingCallbackHttpResponse. The spec incorrectly wrapped the return type inopt, which no real gateway accepts — candid cannot coerce wire-typeopt Tinto the expectedT, 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 blockdocs/references/http-gateway-protocol-spec.md— Response Body Streaming Interface blockNote: only the callback's return type changes. The
token : opt Tokenfield insideStreamingCallbackHttpResponsestays 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-gateway→ic-http-gateway-protocol(tagv0.5.1) →ic-agent/ic-utilsic-http-gateway-protocol@ v0.5.1 —response_handler.rs#L116-L120: callshttp_request_stream_callbackand matchesOk((StreamingCallbackHttpResponse { body, token },))— the bare struct, noOption.ic-agent—ic-utils/src/interfaces/http_request.rs:http_request_stream_callback -> SyncCall<Value = (StreamingCallbackHttpResponse,)>, and the callback CandidTypefunc((ArgToken) -> (StreamingCallbackHttpResponse) query).Detected while adding e2e streaming tests for certified-assets (dfinity/certified-assets#96).
npm run buildpasses.