siyuan-note/siyuan · error

failed to convert request value to object

Error message

failed to convert request value to object

What it means

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.

Source

Thrown at kernel/plugin/plugin.go:1056

	var bufferedAmount atomic.Int64
	readyState.Store(int64(WebSocketReadyStateConnecting))

	runErr := p.worker.Run(func(rt *goja.Runtime) (_ any, err error) {
		handler, handlerObj, getHandlerErr := getRequestHandler(rt, scope, RequestTypeWS)
		if getHandlerErr != nil {
			err = getHandlerErr
			return
		}

		jsRequest, convertErr := requestGoToJs(p, rt, request)
		if convertErr != nil {
			err = convertErr
			return
		}

		jsRequestObj := jsRequest.ToObject(rt)
		if jsRequestObj == nil {
			err = fmt.Errorf("failed to convert request value to object")
			return
		}

		port := rt.NewObject()

		invokePortHook := func(_ *goja.Runtime, name string, args ...goja.Value) {
			hook := port.Get(name)
			if fn, ok := goja.AssertFunction(hook); ok {
				if _, callErr := fn(port, args...); callErr != nil {
					logging.LogErrorf("[plugin:%s] ws server port hook %q: %v", p.Name, name, callErr)
				}
			}
		}

		setProtocol := func(rt *goja.Runtime, protocol string) {
			port.Set("protocol", rt.ToValue(protocol))
		}

View on GitHub (pinned to 251596fc0d)

Solutions

  1. Report to the SiYuan issue tracker with the plugin name, request method/path, and kernel version.
  2. Retry with a simpler request (plain headers, no body) to see if a specific field triggers the conversion failure.
  3. Update to the latest kernel; this guard is defensive and a hit usually means a fixed bug.
Defensive patterns

Strategy: try-catch

Try / catch

// internal; surface and report
try { /* ws handler registration */ } catch (e) { if (/convert request value to object/.test(String(e))) reportToMaintainer(e); else throw e; }

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Related errors


AI-assisted analysis of siyuan-note/siyuan@251596fc0d (2026-08-12). Data as JSON: /api/errors/4a505e41021a4cdc. Report an issue: GitHub.