clockworklabs/SpacetimeDB · error · InvalidOperationException

Invalid HTTP method returned from host

Error message

Invalid HTTP method returned from host

What it means

FromWireMethod maps the HttpMethodWire sum type received from the host onto the SDK's HttpMethod. The switch covers the nine standard methods plus the Extension fallback; reaching the default arm means the decoded value does not correspond to any known tag - realistically only possible when host and SDK disagree on the wire schema. The exception is caught and returned as HttpError rather than crashing the procedure.

Source

Thrown at crates/bindings-csharp/Runtime/Http.cs:470

                Code = response.StatusCode,
            },
            response.Body.ToBytes()
        );

    private static HttpMethod FromWireMethod(HttpMethodWire methodWire) =>
        methodWire switch
        {
            HttpMethodWire.Get => HttpMethod.Get,
            HttpMethodWire.Head => HttpMethod.Head,
            HttpMethodWire.Post => HttpMethod.Post,
            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)

View on GitHub (pinned to 524b4487d9)

Solutions

  1. Upgrade the C# SDK NuGet to the version matching the SpacetimeDB host, then rebuild and redeploy the module
  2. Verify spacetimedb CLI, server, and SDK all sit on the same release line
  3. Treat the accompanying HttpError as a deployment/compatibility problem - do not retry the request
  4. Report persistent mismatches with host and SDK version numbers
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 method returned from host") => null, // host/SDK skew
    onErr: err => throw new InvalidOperationException(err.ToString()));

Prevention

When it happens

Trigger: A host newer than the SDK sends a HttpMethodWire variant the SDK's BSATN definitions decode into an unmatched value; schema drift in the FFI wire types after a partial upgrade.

Common situations: Host upgraded ahead of the module SDK; custom/edge host builds; beta channel versions adding new HTTP method handling.

Related errors


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