siyuan-note/siyuan · error
path required
Error message
path required
What it means
siyuan.client.fetch requires its first argument to be a string request path. When the argument is not a string (or missing/undefined), the bridge rejects the promise with "path required". The client only supports string-path requests like "/api/...".
Solutions
- Pass the API path as a string first argument: siyuan.client.fetch("/api/...", {method:"POST", ...})
- If you have a URL object, pass url.pathname instead
- Ensure the path variable is defined before the call
- Coerce safely: if (typeof path === "string") await siyuan.client.fetch(path)
Example fix
// before
await siyuan.client.fetch({ url: "/api/notebook/lsNotebooks", method: "GET" })
// after
await siyuan.client.fetch("/api/notebook/lsNotebooks", { method: "GET" }) Defensive patterns
Strategy: validation
Validate before calling
function assertPathArg(args) {
if (typeof args[0] !== "string") throw new TypeError("siyuan.client.fetch requires a string path as the first argument");
} Type guard
const isFetchPath = (v) => typeof v === "string" && v.length > 0;
Try / catch
try {
const res = await siyuan.client.fetch(path, opts);
} catch (e) {
if (String(e).includes("path required")) {
console.error("fetch() first argument must be a string path, got:", typeof path);
}
} Prevention
- Always pass the path as the first string argument, options object second
- Do not use fetch({url}) style signatures from other libraries
- Check that interpolated path variables are defined
When it happens
Trigger: Calling siyuan.client.fetch() with no arguments, with a URL object, with an options object as the first argument (Node-fetch style: fetch({url:...})), or with null/undefined.
Common situations: Developers used to browser fetch({url}) or got/axios signatures pass a config object first; template variables interpolating to undefined.
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
- failed to export headers
- path must start with /
- document IDs are required
- panic during siyuan.client.fetch
- Access to encrypted notebook data is not supported via this…
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/33a942f5eab9a226.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/plugin/api_client.go:61
}
}()
client := rt.NewObject()
lo.Must0(client.Set("fetch", rt.ToValue(func(call goja.FunctionCall, rt *goja.Runtime) goja.Value {
promise, resolve, reject := rt.NewPromise()
var argErr error
var path string
method := "GET"
headers := map[string]string{}
var bodyString *string
var bodyBytes *[]byte
if goja.IsString(call.Argument(0)) {
path = call.Argument(0).String()
} else {
argErr = fmt.Errorf("path required")
}
if argErr == nil && !strings.HasPrefix(path, "/") {
argErr = fmt.Errorf("path must start with /")
}
if argErr == nil {
if init := call.Argument(1); isJsValueNotNull(init) {
if initObj := init.ToObject(rt); initObj != nil {
if m := initObj.Get("method"); goja.IsString(m) {
method = m.String()
}
if h := initObj.Get("headers"); isJsValueNotNull(h) {
if exportErr := rt.ExportTo(h, &headers); exportErr != nil {
argErr = fmt.Errorf("failed to export headers: %w", exportErr)
}
}
if argErr == nil {View on GitHub (pinned to 9f775e8a12)