{"record":{"id":"8870a8f7fdf37128","repo":"siyuan-note/siyuan","slug":"invalid-jsonrpc-version-s","errorCode":null,"errorMessage":"invalid jsonrpc version: %s","messagePattern":"invalid jsonrpc version: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/plugin/rpc.go","lineNumber":114,"sourceCode":"\tdecoder := json.NewDecoder(bytes.NewReader(data))\n\t// decoder.DisallowUnknownFields() // Reject unknown fields violates the JSON-RPC spec\n\ttype JsonRpcRequestObject struct {\n\t\tJsonRpc util.Optional[string] `json:\"jsonrpc\"`\n\t\tMethod  util.Optional[string] `json:\"method\"`\n\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","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/plugin/rpc.go#L96-L132","documentation":"Returned when the jsonrpc field exists but its value is not exactly \"2.0\" (JsonRpcVersion). The version string is interpolated into the message so the offending value is visible. Any other version (1.0, 2, \"2\") is rejected.","triggerScenarios":"Client sends {\"jsonrpc\":\"2.0\"...} with a typo, or \"jsonrpc\":\"1.0\"/\"2\", or a numeric 2 instead of the string \"2.0\".","commonSituations":"Wrong spec version from a legacy client, a string/number coercion bug, or copy-paste from JSON-RPC 1.0 docs.","solutions":["Use exactly the string \"2.0\" for jsonrpc.","Centralize envelope construction so the version is not hand-typed per call.","Log the raw body on this error to see what value was sent."],"exampleFix":"// before\n{ jsonrpc: 2, id: 1, method: 'm' }\n\n// after\n{ jsonrpc: '2.0', id: 1, method: 'm' }","handlingStrategy":"validation","validationCode":"if (req.jsonrpc !== '2.0') throw new Error('jsonrpc must be exactly \"2.0\"');","typeGuard":"function isJsonRpc2(o: unknown): boolean { return !!o && typeof o === 'object' && (o as any).jsonrpc === '2.0'; }","tryCatchPattern":null,"preventionTips":["Hard-code the version string '2.0' in one place.","Do not coerce the version to a number.","Log the raw request body when this error appears."],"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"}