{"record":{"id":"0532073b55a83671","repo":"siyuan-note/siyuan","slug":"invalid-id-field-must-be-string-number-null-or","errorCode":null,"errorMessage":"invalid id field: must be string, number, null or omitted","messagePattern":"invalid id field: must be string, number, null or omitted","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/plugin/rpc.go","lineNumber":128,"sourceCode":"\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\n// IsNotification returns true if this request is a notification (no ID field).\nfunc (r *JsonRpcRequest) IsNotification() bool {\n\treturn r.ID.Exists == false\n}\n\n// Validate validates the JSON-RPC request structure.\nfunc (r *JsonRpcRequest) Validate() *JsonRpcError {\n\t// params is optional, but if present must be either an array (for positional parameters) or an object (for named parameters)\n\tif !r.Params.Exists {","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/plugin/rpc.go#L110-L146","documentation":"Returned when the id field is present but is neither a string, a number (float64 after JSON decode), nor null. The kernel allows id to be omitted (notification), null, a string, or a number; booleans, objects, and arrays are rejected per the JSON-RPC 2.0 spec.","triggerScenarios":"Client sends {\"jsonrpc\":\"2.0\",\"method\":\"m\",\"id\":true} or id as an object/array.","commonSituations":"Reusing a JS boolean or object as an id, or a serialization quirk that wraps id in an extra layer.","solutions":["Use a string or integer id, or null/omit it for notifications.","Generate ids from a counter: let id = 0; ... id: ++id.","Validate typeof id === 'string' || typeof id === 'number' before sending."],"exampleFix":"// before\n{ jsonrpc: '2.0', id: { batch: 1 }, method: 'm' }\n\n// after\n{ jsonrpc: '2.0', id: 'batch-1', method: 'm' }","handlingStrategy":"type-guard","validationCode":"function isValidId(id: unknown): boolean { return id === undefined || id === null || typeof id === 'string' || typeof id === 'number'; }","typeGuard":"function isJsonRpcId(id: unknown): id is string | number | null | undefined { return id === undefined || id === null || typeof id === 'string' || typeof id === 'number'; }","tryCatchPattern":null,"preventionTips":["Use string or integer ids only.","Generate ids from a counter.","Never use booleans/objects/arrays as id."],"tags":["plugin","rpc","jsonrpc","validation","types"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}