{"record":{"id":"4a505e41021a4cdc","repo":"siyuan-note/siyuan","slug":"failed-to-convert-request-value-to-object","errorCode":null,"errorMessage":"failed to convert request value to object","messagePattern":"failed to convert request value to object","errorType":"exception","errorClass":null,"httpStatus":500,"severity":"error","filePath":"kernel/plugin/plugin.go","lineNumber":1056,"sourceCode":"\tvar bufferedAmount atomic.Int64\n\treadyState.Store(int64(WebSocketReadyStateConnecting))\n\n\trunErr := p.worker.Run(func(rt *goja.Runtime) (_ any, err error) {\n\t\thandler, handlerObj, getHandlerErr := getRequestHandler(rt, scope, RequestTypeWS)\n\t\tif getHandlerErr != nil {\n\t\t\terr = getHandlerErr\n\t\t\treturn\n\t\t}\n\n\t\tjsRequest, convertErr := requestGoToJs(p, rt, request)\n\t\tif convertErr != nil {\n\t\t\terr = convertErr\n\t\t\treturn\n\t\t}\n\n\t\tjsRequestObj := jsRequest.ToObject(rt)\n\t\tif jsRequestObj == nil {\n\t\t\terr = fmt.Errorf(\"failed to convert request value to object\")\n\t\t\treturn\n\t\t}\n\n\t\tport := rt.NewObject()\n\n\t\tinvokePortHook := func(_ *goja.Runtime, name string, args ...goja.Value) {\n\t\t\thook := port.Get(name)\n\t\t\tif fn, ok := goja.AssertFunction(hook); ok {\n\t\t\t\tif _, callErr := fn(port, args...); callErr != nil {\n\t\t\t\t\tlogging.LogErrorf(\"[plugin:%s] ws server port hook %q: %v\", p.Name, name, callErr)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tsetProtocol := func(rt *goja.Runtime, protocol string) {\n\t\t\tport.Set(\"protocol\", rt.ToValue(protocol))\n\t\t}\n","sourceCodeStart":1038,"sourceCodeEnd":1074,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/plugin/plugin.go#L1038-L1074","documentation":"Returned inside the WebSocket request setup when requestGoToJs succeeded but jsRequest.ToObject(rt) returns nil, meaning the converted request value is a primitive/null rather than an object. This is a kernel-side conversion failure, not something the JS handler controls directly.","triggerScenarios":"A WebSocket server handler is dispatched but the internal Go->JS request bridge produced a non-object value (defensive guard; should not normally fire unless requestGoToJs has a bug).","commonSituations":"Effectively an internal error. Seen if a kernel build introduces a regression in requestGoToJs, or an exotic request type fails to map to a goja object.","solutions":["Report to the SiYuan issue tracker with the plugin name, request method/path, and kernel version.","Retry with a simpler request (plain headers, no body) to see if a specific field triggers the conversion failure.","Update to the latest kernel; this guard is defensive and a hit usually means a fixed bug."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// internal; surface and report\ntry { /* ws handler registration */ } catch (e) { if (/convert request value to object/.test(String(e))) reportToMaintainer(e); else throw e; }","preventionTips":["Treat this as an internal kernel error; report with request details.","Keep the kernel updated.","Simplify request shape to isolate a conversion bug."],"tags":["plugin","server","websocket","internal-bug"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}