Skip to content

Comments

fix: Handle empty HTTP response body in procedure bindings#4386

Merged
gefjon merged 1 commit intoclockworklabs:masterfrom
Ludv1gL:fix/empty-http-response-body
Feb 21, 2026
Merged

fix: Handle empty HTTP response body in procedure bindings#4386
gefjon merged 1 commit intoclockworklabs:masterfrom
Ludv1gL:fix/empty-http-response-body

Conversation

@Ludv1gL
Copy link
Contributor

@Ludv1gL Ludv1gL commented Feb 21, 2026

Summary

  • create_bytes_source() in the host returns BytesSourceId::INVALID for empty response bodies, but HttpClient::send() unconditionally reads the body source via read_bytes_source_into(), which panics with "invalid source passed"
  • Any procedure HTTP request returning an empty body (e.g. HTTP 200 with no content from a successful reducer call) triggers this panic
  • Fix: check for BytesSource::INVALID before reading, matching the existing pattern used for JWT payloads in bindings-sys

Test plan

  • Verified cargo check -p spacetimedb passes
  • Trigger an HTTP request from a procedure that returns an empty response body (e.g. calling a reducer via HTTP that returns 200 with no body)
  • Verify no panic occurs and an empty Body is returned

🤖 Generated with Claude Code

`create_bytes_source()` returns `BytesSourceId::INVALID` for empty
response bodies, but `HttpClient::send()` unconditionally tries to
read the body source via `read_bytes_source_into()`, which panics
on the INVALID handle ("invalid source passed").

This affects any procedure making an HTTP request that returns an
empty body (e.g. HTTP 200 with no content).

Check for `BytesSource::INVALID` before reading, returning an empty
`Body` instead. This matches the existing pattern used for JWT
payloads in `bindings-sys` (line 1455).

The doc comment on `bytes_source_remaining_length` already warns:
"the special `BytesSource::INVALID` (zero) is always invalid.
Callers should check for that value before invoking this function."
@gefjon gefjon added bugfix Fixes something that was expected to work differently release-2.0 release-2.0-nice-to-have labels Feb 21, 2026
@gefjon gefjon enabled auto-merge February 21, 2026 03:36
@gefjon gefjon added this pull request to the merge queue Feb 21, 2026
Merged via the queue into clockworklabs:master with commit d2223a2 Feb 21, 2026
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Fixes something that was expected to work differently release-2.0-nice-to-have release-2.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants