siyuan-note/siyuan · error
missing method field
Error message
missing method field
What it means
Returned when the request has a valid jsonrpc field but the method field is absent (util.Optional.HasValue() is false). A JSON-RPC request without a method is invalid; notifications still require method (they just omit id).
Source
Thrown at kernel/plugin/rpc.go:119
Params util.Optional[any] `json:"params"`
ID util.Optional[any] `json:"id"`
}
request := JsonRpcRequestObject{}
if err := decoder.Decode(&request); err != nil {
return err
}
// Validate jsonrpc field
if !request.JsonRpc.Exists {
return fmt.Errorf("missing jsonrpc field")
}
if request.JsonRpc.Value != JsonRpcVersion {
return fmt.Errorf("invalid jsonrpc version: %s", request.JsonRpc.Value)
}
// Validate method field
if !request.Method.HasValue() {
return fmt.Errorf("missing method field")
}
// Validate id field
if !request.ID.Exists {
} else if request.ID.IsNull {
} else if _, ok := request.ID.Value.(string); ok {
} else if _, ok := request.ID.Value.(float64); ok {
} else {
return fmt.Errorf("invalid id field: must be string, number, null or omitted")
}
r.JsonRpc = request.JsonRpc.Value
r.Method = request.Method.Value
r.Params = request.Params
r.ID = request.ID
return nil
}
View on GitHub (pinned to 251596fc0d)
Solutions
- Always include a non-empty "method" string in the request.
- Use a typed RPC client that forces method as a required parameter.
- Check the field name spelling against the JSON-RPC 2.0 spec.
Example fix
// before
{ jsonrpc: '2.0', id: 1, action: 'doStuff', params: [] }
// after
{ jsonrpc: '2.0', id: 1, method: 'doStuff', params: [] } Defensive patterns
Strategy: validation
Validate before calling
if (typeof req.method !== 'string' || req.method.length === 0) throw new Error('method required'); Type guard
function hasMethod(o: unknown): o is { method: string } { return !!o && typeof o === 'object' && typeof (o as any).method === 'string' && (o as any).method.length > 0; } Prevention
- Always include a non-empty method string.
- Use a typed RPC client that requires method.
- Check field name spelling against the spec.
When it happens
Trigger: Client sends {"jsonrpc":"2.0","id":1,"params":[]} with no method, or a payload where method is null/omitted.
Common situations: Typo in the field name (e.g. 'action' instead of 'method'), or a generic envelope reused for results/errors that lacks method.
Related errors
- missing jsonrpc field
- invalid jsonrpc version: %s
- invalid id field: must be string, number, null or omitted
- Agent capability name and description are required
- plugin [%s] not found
AI-assisted analysis of siyuan-note/siyuan@251596fc0d (2026-08-12).
Data as JSON: /api/errors/ce8ed29c464b3603.
Report an issue: GitHub.