siyuan-note/siyuan · error
method required
Error message
method required
What it means
This is the siyuan.server-style RPC request API in api_rpc.go: it requires the target method name as its first argument. With zero arguments the promise rejects with 'method required' because there is nothing to dispatch to. The call is asynchronous; the error surfaces via the returned promise.
Solutions
- Pass the method name string as the first argument: rpc('methodName')
- If params are needed, pass them as the second argument: rpc('methodName', params)
- Validate the dynamic argument array is non-empty before spreading it into the call
Example fix
// before
const args = []
await siyuan.rpc(...args)
// after
await siyuan.rpc('methodName', { foo: 1 }) Defensive patterns
Strategy: validation
Validate before calling
if (args.length === 0) throw new Error('rpc requires a method name')
await siyuan.rpc(...args) Try / catch
try { await siyuan.rpc(method, params) } catch (e) { if (e.message === 'method required') { /* fix call site */ } else throw e } Prevention
- Always call rpc with a literal method name first argument
- Validate dynamically built argument arrays before spreading
- Centralize rpc calls in a wrapper that asserts the method name
When it happens
Trigger: Calling the RPC request function with no arguments, e.g. rpc() or rpc() after spreading an empty array: rpc(...[]).
Common situations: Building the argument list dynamically from config and the config being empty; forgetting the method argument when only params were intended; a refactor that moved the method name into an options object the kernel does not accept.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- method name required
- method name and function required
- path required
- second argument must be a function
- assetPath is required for analyze
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/bc49adabcbc0b898.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/plugin/api_rpc.go:147
})
if runErr != nil {
logging.LogErrorf("[plugin:%s] siyuan.rpc.unbind worker run: %v", p.Name, runErr)
if rejectErr := reject(rt.NewGoError(runErr)); rejectErr != nil {
logging.LogErrorf("[plugin:%s] siyuan.rpc.unbind reject: %v", p.Name, rejectErr)
}
}
return rt.ToValue(promise)
})))
lo.Must0(rpc.Set("broadcast", rt.ToValue(func(call goja.FunctionCall, rt *goja.Runtime) goja.Value {
promise, resolve, reject := rt.NewPromise()
var argErr error
var method string
var params util.Optional[any]
if len(call.Arguments) < 1 {
argErr = fmt.Errorf("method required")
} else {
if m := call.Argument(0); goja.IsString(m) {
method = m.String()
} else {
argErr = fmt.Errorf("first argument must be method name string")
}
if argErr == nil {
arg := call.Argument(1)
if goja.IsUndefined(arg) {
params.Value = nil
params.Exists = false
params.IsNull = false
} else if goja.IsNull(arg) {
params.Value = nil
params.Exists = true
params.IsNull = true
} else {
params.Value = arg.Export()View on GitHub (pinned to 9f775e8a12)