{"record":{"id":"8d8909136b3e3b7d","repo":"siyuan-note/siyuan","slug":"invalid-agent-runtime-revision","errorCode":null,"errorMessage":"invalid agent runtime revision","messagePattern":"invalid agent runtime revision","errorType":"http","errorClass":null,"httpStatus":200,"severity":"error","filePath":"kernel/agent/runtime.go","lineNumber":210,"sourceCode":"\tdata, err := os.ReadFile(runtimePath(sessionID))\n\tif err != nil {\n\t\tif os.IsNotExist(err) {\n\t\t\treturn &agentRuntime{SchemaVersion: 1, SessionID: sessionID}, nil\n\t\t}\n\t\treturn nil, err\n\t}\n\tvar runtime agentRuntime\n\tif err := gulu.JSON.UnmarshalJSON(data, &runtime); err != nil {\n\t\treturn nil, err\n\t}\n\tif runtime.SchemaVersion > 1 {\n\t\treturn nil, fmt.Errorf(\"unsupported agent runtime schema version: %d\", runtime.SchemaVersion)\n\t}\n\tif runtime.SessionID != \"\" && runtime.SessionID != sessionID {\n\t\treturn nil, fmt.Errorf(\"agent runtime session id mismatch\")\n\t}\n\tif runtime.Revision < 0 {\n\t\treturn nil, fmt.Errorf(\"invalid agent runtime revision\")\n\t}\n\tif runtime.ActiveTurn != nil {\n\t\tif runtime.ActiveTurn.TurnID == \"\" {\n\t\t\treturn nil, fmt.Errorf(\"invalid agent runtime turn id\")\n\t\t}\n\t\tswitch runtime.ActiveTurn.State {\n\t\tcase \"running\", \"finished\", \"interrupted\":\n\t\tdefault:\n\t\t\treturn nil, fmt.Errorf(\"invalid agent runtime turn state\")\n\t\t}\n\t}\n\tif runtime.SchemaVersion == 0 {\n\t\truntime.SchemaVersion = 1\n\t}\n\tif runtime.SessionID == \"\" {\n\t\truntime.SessionID = sessionID\n\t}\n\treturn &runtime, nil","sourceCodeStart":192,"sourceCodeEnd":228,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/afa823b6b4e4f183511e0bc0a3be93caa94c7c97/kernel/agent/runtime.go#L192-L228","documentation":"Rejected by siyuan.rpc.broadcast(method, params) when called with no arguments (kernel/plugin/api_rpc.go:147). Broadcasting invokes a bound RPC method on all connected clients, and the method name is mandatory; params are optional and may be omitted, but the name may not.","triggerScenarios":"siyuan.rpc.broadcast() with the method forgotten; broadcast(params) passing only the payload; spread calls broadcast(...args) with an empty args array.","commonSituations":"Fire-and-forget notification code where the method constant was inlined elsewhere; refactors moving params construction earlier and dropping the name; optional-chained config giving undefined for the method.","solutions":["Always pass the method string first: siyuan.rpc.broadcast('myplugin.notify', payload)","Default the method from a constant so it can never be omitted","Guard spreads: if (args.length >= 1 && typeof args[0] === 'string')"],"exampleFix":"// before\nsiyuan.rpc.broadcast(payload); // name missing\n\n// after\nsiyuan.rpc.broadcast('myplugin.notify', payload);","handlingStrategy":"type-guard","validationCode":"if (typeof method === 'string' && method.length > 0) siyuan.rpc.broadcast(method, params);","typeGuard":"const isRpcName = (v) => typeof v === 'string' && v.length > 0;","tryCatchPattern":"try { siyuan.rpc.broadcast(method, params); } catch (e) { if (/method required/.test(e.message)) throw new TypeError('broadcast called without a method name'); else throw e; }","preventionTips":["Always call broadcast(methodName, params) — name first","Default to a constant notification method in shared helpers","Guard spread-based calls for arity"],"tags":["rpc","plugin-api","argument-validation","siyuan"],"backgroundTag":"missing-required-argument","analyzedSha":"afa823b6b4e4f183511e0bc0a3be93caa94c7c97","analyzedAt":"2026-08-18T17:04:10.865Z","schemaVersion":2},"datasetVersion":"2026-08-24T22:17:12.610Z"}