{"record":{"id":"7bde2e7a1d7a935d","repo":"siyuan-note/siyuan","slug":"objectsetdatamethods-v","errorCode":null,"errorMessage":"ObjectSetDataMethods: %v","messagePattern":"ObjectSetDataMethods: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/plugin/sandbox.go","lineNumber":160,"sourceCode":"\tif Object == nil {\n\t\treturn fmt.Errorf(\"globalThis.Object is not an object\")\n\t}\n\n\tseal, ok := goja.AssertFunction(Object.Get(\"seal\"))\n\tif !ok {\n\t\treturn fmt.Errorf(\"globalThis.Object.seal is not a function\")\n\t}\n\n\t_, err := seal(Object, obj)\n\treturn err\n}\n\n// ObjectSetDataMethods attaches text(), json(), buffer() and arrayBuffer() methods to a JS object,\n// each returning a Promise that resolves with the corresponding representation of data.\nfunc ObjectSetDataMethods(p *KernelPlugin, rt *goja.Runtime, object *goja.Object, data []byte) (err error) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\terr = fmt.Errorf(\"ObjectSetDataMethods: %v\", r)\n\t\t}\n\t}()\n\n\tlo.Must0(object.Set(\"text\", rt.ToValue(func(call goja.FunctionCall, rt *goja.Runtime) goja.Value {\n\t\tpromise, resolve, reject := rt.NewPromise()\n\n\t\trunErr := p.worker.Run(func(rt *goja.Runtime) (result any, err error) {\n\t\t\tresult = string(data)\n\t\t\treturn\n\t\t}, func(rt *goja.Runtime, result any, err error) {\n\t\t\tif lo.IsNil(err) {\n\t\t\t\tif resolveErr := resolve(result); resolveErr != nil {\n\t\t\t\t\tlogging.LogErrorf(\"[plugin:%s] data.text() resolve: %v\", p.Name, resolveErr)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif rejectErr := reject(rt.NewGoError(err)); rejectErr != nil {\n\t\t\t\t\tlogging.LogErrorf(\"[plugin:%s] data.text() reject: %v\", p.Name, rejectErr)\n\t\t\t\t}","sourceCodeStart":142,"sourceCodeEnd":178,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/plugin/sandbox.go#L142-L178","documentation":"A recovered panic from ObjectSetDataMethods, the helper that attaches text()/json()/buffer()/arrayBuffer() to a JS object (used to give Response.body.raw or similar a way to materialize bytes). Any panic while calling object.Set for those methods is caught and wrapped.","triggerScenarios":"A nil object is passed in, or the goja runtime is in a bad state when attaching the methods, causing object.Set to panic.","commonSituations":"Internal; surfaces while materializing a response/data object. Almost always a symptom of an earlier nil/context error, not a direct plugin mistake.","solutions":["Inspect the kernel log for the preceding error that left the object/runtime in a bad state.","Update the kernel; this is a defensive guard against a should-not-happen condition.","Simplify the response body (avoid large/binary payloads) to see if a specific code path triggers it.","Report the panic value and plugin name if reproducible."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// internal; surface the prior error\ntry { /* use response data methods */ } catch (e) { if (/ObjectSetDataMethods/.test(String(e))) report(e); else throw e; }","preventionTips":["Treat as a symptom of an earlier nil/context error; inspect the log.","Keep the kernel updated.","Simplify response bodies to isolate the trigger and report."],"tags":["plugin","sandbox","response","panic","internal-bug"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}