clockworklabs/SpacetimeDB · error · InvalidOperationException
Invalid HTTP version returned from host
Error message
Invalid HTTP version returned from host
What it means
Companion of the HTTP-method check: FromWireVersion maps HttpVersionWire.Http09/Http10/Http11/Http2/Http3 and throws on anything else. The wire value comes straight from the host response; an unrecognized tag means the host's encoding and this bindings build disagree on the HttpVersionWire enum, or the byte stream is misaligned/corrupted.
Solutions
- Match host and bindings versions (upgrade the SpacetimeDB packages to the server's release)
- Validate the surrounding response fields decode correctly — a wrong earlier field size shifts the reader and corrupts the version tag
- Log the raw bytes at the FFI boundary and file a SpacetimeDB issue if skew is confirmed
Defensive patterns
Strategy: try-catch
Try / catch
try { var version = FromWireVersion(responseWire.Version); }
catch (InvalidOperationException ioe) when (ioe.Message.Contains("Invalid HTTP version"))
{
// unrecognized wire enum: version skew or misaligned stream — stop parsing this response
} Prevention
- Keep host and bindings versions aligned on upgrade
- If mismatched decoding is suspected, verify earlier response fields parsed correctly before blaming the version tag
- Capture raw FFI payloads in debug builds for quick skew diagnosis
When it happens
Trigger: Host sends an HTTP version tag outside Http09..Http3 — newer host with an added version, or a misaligned BinaryReader (earlier field of the response decoded with the wrong size) making the version field read a bogus tag.
Common situations: Host/bindings version skew after a spacetimedb upgrade; schema drift in the HTTP wire types; stream corruption through a misbehaving proxy; unit tests replaying captured response bytes against a newer runtime.
Related errors
- Invalid HTTP method returned from host
- Cannot nest router at
- Pre-publish check failed with status
- Route conflict for
- Route paths may contain only
AI-assisted analysis of clockworklabs/SpacetimeDB@6dee26c6ef (2026-08-20).
Data as JSON: /api/errors/5709c50f8eb5ad5d.
Report an issue: GitHub.
Appendix: source
Thrown at crates/bindings-csharp/Runtime/Http.cs:481
HttpMethodWire.Put => HttpMethod.Put,
HttpMethodWire.Delete => HttpMethod.Delete,
HttpMethodWire.Connect => HttpMethod.Connect,
HttpMethodWire.Options => HttpMethod.Options,
HttpMethodWire.Trace => HttpMethod.Trace,
HttpMethodWire.Patch => HttpMethod.Patch,
HttpMethodWire.Extension(var extension) => new HttpMethod(extension),
_ => throw new InvalidOperationException("Invalid HTTP method returned from host"),
};
private static HttpVersion FromWireVersion(HttpVersionWire versionWire) =>
versionWire switch
{
HttpVersionWire.Http09 => HttpVersion.Http09,
HttpVersionWire.Http10 => HttpVersion.Http10,
HttpVersionWire.Http11 => HttpVersion.Http11,
HttpVersionWire.Http2 => HttpVersion.Http2,
HttpVersionWire.Http3 => HttpVersion.Http3,
_ => throw new InvalidOperationException("Invalid HTTP version returned from host"),
};
private static (
ushort statusCode,
HttpVersion version,
List<HttpHeader> headers
) FromWireResponse(HttpResponseWire responseWire)
{
var version = FromWireVersion(responseWire.Version);
var headers = responseWire
.Headers.Entries.Select(h => new HttpHeader(h.Name, h.Value, false))
.ToList();
return (responseWire.Code, version, headers);
}
}
View on GitHub (pinned to 6dee26c6ef)