{"record":{"id":"4017554ae1d80700","repo":"siyuan-note/siyuan","slug":"invalid-event-object","errorCode":null,"errorMessage":"invalid event object","messagePattern":"invalid event object","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/plugin/plugin.go","lineNumber":1403,"sourceCode":"\t\t\t\t\t}\n\n\t\t\t\t\tif event := eventObj.Get(\"event\"); goja.IsString(event) {\n\t\t\t\t\t\te.Event = event.String()\n\t\t\t\t\t}\n\n\t\t\t\t\tif id := eventObj.Get(\"id\"); goja.IsString(id) {\n\t\t\t\t\t\te.Id = id.String()\n\t\t\t\t\t}\n\n\t\t\t\t\tif retry := eventObj.Get(\"retry\"); goja.IsNumber(retry) {\n\t\t\t\t\t\te.Retry = uint(retry.ToInteger())\n\t\t\t\t\t}\n\n\t\t\t\t\tevents.In <- e\n\t\t\t\t\treturn goja.Undefined()\n\t\t\t\t}\n\t\t\t}\n\t\t\tpanic(rt.NewGoError(fmt.Errorf(\"invalid event object\")))\n\t\t})\n\n\t\tport_close := rt.ToValue(func(call goja.FunctionCall, rt *goja.Runtime) goja.Value {\n\t\t\tdoClose()\n\t\t\treturn goja.Undefined()\n\t\t})\n\n\t\tlo.Must0(port.Set(\"onopen\", goja.Null()))\n\t\tlo.Must0(port.Set(\"onclose\", goja.Null()))\n\n\t\tlo.Must0(port.Set(\"send\", port_send))\n\t\tlo.Must0(port.Set(\"close\", port_close))\n\n\t\tlo.Must0(ObjectSeal(rt, port))\n\n\t\tlo.Must0(jsRequestObj.Set(\"port\", port))\n\n\t\tinvokeFunction(func(_ *goja.Runtime, result *CallResult) {","sourceCodeStart":1385,"sourceCodeEnd":1421,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/plugin/plugin.go#L1385-L1421","documentation":"Panicked when the SSE port.send() first argument is null/undefined OR is a value that cannot be turned into an object (ToObject returns nil). Distinct from missing-data: this means there is no usable event object at all to read fields from.","triggerScenarios":"Calling port.send(), port.send(null), or port.send(undefined); or passing a primitive (number/string) where an event object is expected.","commonSituations":"Forwarding an optional event variable that is sometimes undefined, or calling send with no args to 'ping' the stream.","solutions":["Always pass an event object: port.send({ data: '...' }).","Use port.close() to end the stream instead of an empty send.","Guard: if (!event) return; before port.send(event)."],"exampleFix":"// before\nport.send(maybeEvent);\n\n// after\nif (maybeEvent && typeof maybeEvent === 'object' && 'data' in maybeEvent) {\n  port.send(maybeEvent);\n}","handlingStrategy":"type-guard","validationCode":"function isValidEventObject(e: unknown): boolean { return !!e && typeof e === 'object'; }","typeGuard":"function isEventObject(e: unknown): e is { data: unknown; event?: string; id?: string; retry?: number } { return !!e && typeof e === 'object' && 'data' in (e as any); }","tryCatchPattern":"if (!isValidEventObject(event)) return; try { port.send(event); } catch (e) { /* ... */ }","preventionTips":["Never call send() with null/undefined/empty args.","Guard optional event variables before sending.","Use port.close() to end the stream, not an empty send."],"tags":["plugin","server","sse","validation","arguments"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}