clockworklabs/SpacetimeDB · error · InvalidOperationException

Invalid HTTP version returned from host

Error message

Invalid HTTP version returned from host

What it means

FromWireVersion translates the HttpVersionWire sum from the host (Http09 through Http3) into the SDK's HttpVersion enum. Hitting the default arm means the decoded wire value matched none of the known tags, which in practice indicates host/SDK protocol schema drift rather than any client input problem. As with the other host-decode failures, it is converted to Result.Err(HttpError).

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 524b4487d9)

Solutions

  1. Match the module SDK NuGet version to the host version and republish the module
  2. Confirm no component (CLI/server/SDK) is on a different major or preview line
  3. Surfacing this as HttpError is expected - handle it as a compatibility failure and stop issuing HTTP calls until redeployed
  4. File an issue with both version strings if alignment does not resolve it
Defensive patterns

Strategy: fallback

Try / catch

var result = http.Send(request);
return result.Match<HttpResponse?>(
    onOk: resp => resp,
    onErr: err when err.ToString().Contains("Invalid HTTP version returned from host") => null, // protocol drift
    onErr: err => throw new InvalidOperationException(err.ToString()));

Prevention

When it happens

Trigger: Module SDK older than the host receives a HttpVersionWire encoding it cannot map; partial upgrade where only one side of the FFI contract moved.

Common situations: Rolling server upgrades while modules were built with an older SDK; mixing pinned SDK versions across services talking to one host.

Related errors


AI-assisted analysis of clockworklabs/SpacetimeDB@524b4487d9 (2026-08-16). Data as JSON: /api/errors/5709c50f8eb5ad5d. Report an issue: GitHub.