microsoft/typescript-go · error
unknown API method %q
Error message
unknown API method %q
What it means
unmarshalPayload looks the method string up in the server's generated unmarshaler registry; no entry means this server build has never heard of the method. The request fails at payload-decode time and never reaches a handler, so even param-less calls fail.
Source
Thrown at internal/api/proto.go:1454
return resp
}
// NewDiagnosticResponses converts a slice of ast.Diagnostics to DiagnosticResponses.
func NewDiagnosticResponses(diags []*ast.Diagnostic) []*DiagnosticResponse {
if len(diags) == 0 {
return nil
}
result := make([]*DiagnosticResponse, len(diags))
for i, d := range diags {
result[i] = NewDiagnosticResponse(d)
}
return result
}
func unmarshalPayload(method string, payload json.Value) (any, error) {
unmarshaler, ok := unmarshalers[Method(method)]
if !ok {
return nil, fmt.Errorf("unknown API method %q", method)
}
return unmarshaler(payload)
}
func unmarshallerFor[T any](data []byte) (any, error) {
var v T
if err := json.Unmarshal(data, &v); err != nil {
return nil, fmt.Errorf("failed to unmarshal %T: %w", (*T)(nil), err)
}
return &v, nil
}
func noParams(data []byte) (any, error) {
return nil, nil
}
View on GitHub (pinned to 1bcfa18d79)
Solutions
- Check the exact method string against the server's Method constants in proto.go
- Align client and server to the same typescript-go version
- After connecting, negotiate capabilities via initialize and only call methods the server supports
- Trim and normalize method names before sending
Example fix
// before client.Call(ctx, "getdiagnostics", params) // typo // after client.Call(ctx, string(api.MethodGetDiagnostics), params)
Defensive patterns
Strategy: validation
Validate before calling
var supported = map[string]bool{
string(api.MethodInitialize): true,
string(api.MethodGetDiagnostics): true,
// ... keep in sync with the server build
}
if !supported[method] {
return fmt.Errorf("method %q not supported by this server build", method)
}
res, err := client.Call(ctx, method, params) Prevention
- Source method strings from the server's Method constants, never literals
- Negotiate capabilities at initialize and gate calls on them
- Keep client and server versions locked together
When it happens
Trigger: A client on a newer protocol calling a method this server build doesn't have; a typo'd, renamed, or differently-cased method string; whitespace padding around the method name.
Common situations: Version skew after upgrading the client library but not the server; copy-pasted method names; custom methods not registered server-side.
Related errors
- at node %d (kind %v): %w
- %w: unknown message type: %d
- unknown method: %s
- Unsupported OS: ${os}
- Unsupported ARCH: ${arch}
AI-assisted analysis of microsoft/typescript-go@1bcfa18d79 (2026-08-16).
Data as JSON: /api/errors/693462345edeeb72.
Report an issue: GitHub.