{"record":{"id":"36dc83b6cd9f01ad","repo":"siyuan-note/siyuan","slug":"conf-language-0-36dc83","errorCode":null,"errorMessage":"Conf.Language(0)","messagePattern":"Conf\\.Language\\(0\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/file.go","lineNumber":429,"sourceCode":"\t\t\tret.WriteRune('\\\\')\n\t\t}\n\t\tret.WriteRune(r)\n\t}\n\treturn ret.String()\n}\n\ntype FileInfo struct {\n\tpath  string\n\tname  string\n\tsize  int64\n\tisdir bool\n}\n\n// ResolveDocTreeSortMode 按当前父文档、最近祖先文档、笔记本和全局配置的顺序解析子文档排序方式。\nfunc ResolveDocTreeSortMode(boxID, listPath string) (sortMode int, err error) {\n\tbox := Conf.Box(boxID)\n\tif nil == box {\n\t\treturn 0, errors.New(Conf.Language(0))\n\t}\n\n\tnormalized, err := box.validateBoxPath(listPath)\n\tif nil != err {\n\t\treturn 0, err\n\t}\n\tnormalized = filepath.ToSlash(normalized)\n\tif \"\" != normalized {\n\t\tdocPath := \"/\" + strings.TrimPrefix(path.Clean(\"/\"+normalized), \"/\")\n\t\tif !strings.HasSuffix(docPath, \".sy\") {\n\t\t\tdocPath += \".sy\"\n\t\t}\n\n\t\tfor \"\" != docPath && !IsBoxDocPath(boxID, docPath) {\n\t\t\t// 仅探测确实存在的文档，避免将同步中的临时缺失误判为损坏数据。\n\t\t\tif box.Exist(docPath) {\n\t\t\t\tif declared := docSortModeFromIAL(box.docIAL(docPath)); nil != declared {\n\t\t\t\t\treturn *declared, nil","sourceCodeStart":411,"sourceCodeEnd":447,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/file.go#L411-L447","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nfetchPost(\"/api/filetree/listDocsByPath\", {notebook: \"20240101111111-abcdefg\", path: \"/\"})\n// after: use the ID of an open notebook\nfetchPost(\"/api/filetree/listDocsByPath\", {notebook: openNotebooks[0].id, path: \"/\"})","handlingStrategy":"validation","validationCode":"const box = window.siyuan.notebooks.find(nb => nb.id === boxID);\nif (!box) throw new Error(\"notebook not open: \" + boxID);\nawait fetchPost(\"/api/filetree/listDocsByPath\", {notebook: boxID, path: listPath});","typeGuard":"function isOpenNotebook(nb) {\n  return typeof nb?.id === \"string\" && window.siyuan.notebooks.some(b => b.id === nb.id);\n}","tryCatchPattern":"try {\n  const data = await fetchPost(\"/api/filetree/listDocsByPath\", {notebook: boxID, path: \"/\"});\n} catch (e) {\n  if (e.code === -1 && /笔记本|notebook/i.test(e.msg)) {\n    window.siyuan.notebooks = await refreshNotebooks(); // reload IDs and retry\n  }\n}","preventionTips":["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"],"tags":["notebook","filetree","sort-mode"],"backgroundTag":"entity-not-found","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}