siyuan-note/siyuan · error
Conf.Language(0) (notebook not found)
Error message
Conf.Language(0) (notebook not found)
What it means
ResolveDocTreeSortMode resolves the sort mode for a document list by walking parent doc, nearest ancestor doc, notebook, and global config. The very first step looks up Conf.Box(boxID); when no notebook with that ID exists in the current workspace it returns Conf.Language(0) ('Query notebook failed').
Source
Thrown at kernel/model/file.go:414
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 8641553a1f)
Solutions
- Refresh the notebook list (Conf.Box / /api/notebook/lsNotebooks) and use a current box ID.
- Reopen or re-add the missing notebook to the workspace before setting/querying sort mode.
- Validate boxID is non-empty and exists before calling the sort-mode API from scripts.
Example fix
// before
setDocSortMode(staleBoxID, path, sortMode);
// after
const boxes = await fetchPost('/api/notebook/lsNotebooks');
if (boxes.some(b => b.id === boxId)) setDocSortMode(boxId, path, sortMode); Defensive patterns
Strategy: validation
Validate before calling
const boxes = (await fetchPost('/api/notebook/lsNotebooks')).data.notebooks;
if (!boxes.some(b => b.id === boxId)) throw new Error('notebook not open: ' + boxId); Try / catch
try {
await setDocSortMode(boxId, path, mode);
} catch (e) {
await refreshNotebookList(); // recover by reloading current notebook IDs
} Prevention
- Always resolve notebook IDs from a fresh lsNotebooks call, never from long-lived caches
- Handle notebook close/delete events by invalidating stored box IDs
- Check for empty boxID before invoking sort-mode APIs
When it happens
Trigger: Calling ResolveDocTreeSortMode (directly or via ListDocTree/SetDocSortMode) with a boxID that is not an open notebook: stale ID after notebook removal, closed notebook, or typo'd ID from a client.
Common situations: Frontend holding a cached notebook ID after the notebook was deleted or its path removed; sync restoring a tree referencing a removed notebook; API scripts iterating IDs from outdated listings.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
AI-assisted analysis of siyuan-note/siyuan@8641553a1f (2026-09-11).
Data as JSON: /api/errors/08e7fcef22567d33.
Report an issue: GitHub.