{"record":{"id":"ce8ed29c464b3603","repo":"siyuan-note/siyuan","slug":"missing-method-field","errorCode":null,"errorMessage":"missing method field","messagePattern":"missing method field","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/plugin/rpc.go","lineNumber":119,"sourceCode":"\t\tParams  util.Optional[any]    `json:\"params\"`\n\t\tID      util.Optional[any]    `json:\"id\"`\n\t}\n\trequest := JsonRpcRequestObject{}\n\tif err := decoder.Decode(&request); err != nil {\n\t\treturn err\n\t}\n\n\t// Validate jsonrpc field\n\tif !request.JsonRpc.Exists {\n\t\treturn fmt.Errorf(\"missing jsonrpc field\")\n\t}\n\tif request.JsonRpc.Value != JsonRpcVersion {\n\t\treturn fmt.Errorf(\"invalid jsonrpc version: %s\", request.JsonRpc.Value)\n\t}\n\n\t// Validate method field\n\tif !request.Method.HasValue() {\n\t\treturn fmt.Errorf(\"missing method field\")\n\t}\n\n\t// Validate id field\n\tif !request.ID.Exists {\n\t} else if request.ID.IsNull {\n\t} else if _, ok := request.ID.Value.(string); ok {\n\t} else if _, ok := request.ID.Value.(float64); ok {\n\t} else {\n\t\treturn fmt.Errorf(\"invalid id field: must be string, number, null or omitted\")\n\t}\n\n\tr.JsonRpc = request.JsonRpc.Value\n\tr.Method = request.Method.Value\n\tr.Params = request.Params\n\tr.ID = request.ID\n\treturn nil\n}\n","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/plugin/rpc.go#L101-L137","documentation":"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).","triggerScenarios":"Client sends {\"jsonrpc\":\"2.0\",\"id\":1,\"params\":[]} with no method, or a payload where method is null/omitted.","commonSituations":"Typo in the field name (e.g. 'action' instead of 'method'), or a generic envelope reused for results/errors that lacks method.","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."],"exampleFix":"// before\n{ jsonrpc: '2.0', id: 1, action: 'doStuff', params: [] }\n\n// after\n{ jsonrpc: '2.0', id: 1, method: 'doStuff', params: [] }","handlingStrategy":"validation","validationCode":"if (typeof req.method !== 'string' || req.method.length === 0) throw new Error('method required');","typeGuard":"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; }","tryCatchPattern":null,"preventionTips":["Always include a non-empty method string.","Use a typed RPC client that requires method.","Check field name spelling against the spec."],"tags":["plugin","rpc","jsonrpc","validation"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}