siyuan-note/siyuan · error
Conf.Language(0)
Error message
Conf.Language(0)
What it means
ResolveDocTreeSortMode resolves the sort mode for a document tree by walking parent docs, nearest ancestor, notebook and global config. It first looks up the notebook via Conf.Box(boxID); if no notebook with that ID exists in the current configuration it returns Conf.Language(0), the localized "notebook not found" message.
Solutions
- Check the notebook exists and is open: boxID must match an entry in the workspace's notebooks list
- Refresh the frontend document tree so stale notebook IDs are discarded
- Re-open the closed notebook in the UI before listing its documents
- Verify the boxID parameter passed to the API is the notebook ID, not the document path
Example fix
// before
fetchPost("/api/filetree/listDocsByPath", {notebook: "20240101111111-abcdefg", path: "/"})
// after: use the ID of an open notebook
fetchPost("/api/filetree/listDocsByPath", {notebook: openNotebooks[0].id, path: "/"}) Defensive patterns
Strategy: validation
Validate before calling
const box = window.siyuan.notebooks.find(nb => nb.id === boxID);
if (!box) throw new Error("notebook not open: " + boxID);
await fetchPost("/api/filetree/listDocsByPath", {notebook: boxID, path: listPath}); Type guard
function isOpenNotebook(nb) {
return typeof nb?.id === "string" && window.siyuan.notebooks.some(b => b.id === nb.id);
} Try / catch
try {
const data = await fetchPost("/api/filetree/listDocsByPath", {notebook: boxID, path: "/"});
} catch (e) {
if (e.code === -1 && /笔记本|notebook/i.test(e.msg)) {
window.siyuan.notebooks = await refreshNotebooks(); // reload IDs and retry
}
} Prevention
- Re-read the notebook list after any open/close/delete operation
- Never hardcode notebook IDs in scripts; resolve them by name at runtime
- Confirm the notebook is not closed/excluded in the workspace
When it happens
Trigger: Calling ListDocsByPath/ListDocTree or setting sort mode with a boxID that does not exist (notebook closed, removed, or ID typo); calling with an empty or stale notebook ID from a cached frontend reference.
Common situations: Notebook was deleted or its path removed from the workspace while the UI still holds its ID; notebook not opened yet at boot time; programmatic API calls (contract endpoints, tests) passing a fabricated boxID.
Understand the failure class
Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.
Related errors
- Conf.Language(0) (notebook not found)
- Encrypted notebooks do not support this operation
- Please specify the daily note save path in the Notebook…
- Query notebook failed
- 0
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/36dc83b6cd9f01ad.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/model/file.go:429
ret.WriteRune('\\')
}
ret.WriteRune(r)
}
return ret.String()
}
type FileInfo struct {
path string
name string
size int64
isdir bool
}
// ResolveDocTreeSortMode 按当前父文档、最近祖先文档、笔记本和全局配置的顺序解析子文档排序方式。
func ResolveDocTreeSortMode(boxID, listPath string) (sortMode int, err error) {
box := Conf.Box(boxID)
if nil == box {
return 0, errors.New(Conf.Language(0))
}
normalized, err := box.validateBoxPath(listPath)
if nil != err {
return 0, err
}
normalized = filepath.ToSlash(normalized)
if "" != normalized {
docPath := "/" + strings.TrimPrefix(path.Clean("/"+normalized), "/")
if !strings.HasSuffix(docPath, ".sy") {
docPath += ".sy"
}
for "" != docPath && !IsBoxDocPath(boxID, docPath) {
// 仅探测确实存在的文档,避免将同步中的临时缺失误判为损坏数据。
if box.Exist(docPath) {
if declared := docSortModeFromIAL(box.docIAL(docPath)); nil != declared {
return *declared, nilView on GitHub (pinned to 9f775e8a12)