{"record":{"id":"38f990aff4837613","repo":"siyuan-note/siyuan","slug":"block-s-is-not-a-document-that-can-declare-a-ch","errorCode":null,"errorMessage":"block [%s] is not a document that can declare a child document sort mode","messagePattern":"block \\[(.+?)\\] is not a document that can declare a child document sort mode","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/file.go","lineNumber":2490,"sourceCode":"\tID                string `json:\"id\"`\n\tPath              string `json:\"path\"`\n\tSortMode          *int   `json:\"sortMode\"`\n\tEffectiveSortMode int    `json:\"effectiveSortMode\"`\n}\n\n// SetDocSortMode 设置文档对子文档列表声明的排序方式，sortMode 为 nil 时恢复继承。\nfunc SetDocSortMode(id string, sortMode *int) (ret *DocSortModeResult, err error) {\n\tif nil != sortMode && !IsValidDocSortMode(*sortMode) {\n\t\treturn nil, fmt.Errorf(\"invalid document sort mode [%d]\", *sortMode)\n\t}\n\n\tFlushTxQueue()\n\ttree, err := LoadTreeByBlockID(id)\n\tif nil != err {\n\t\treturn nil, err\n\t}\n\tif tree.ID != id || tree.Root.ID != id || ast.NodeDocument != tree.Root.Type || IsBoxDoc(tree.Box, tree.ID) {\n\t\treturn nil, fmt.Errorf(\"block [%s] is not a document that can declare a child document sort mode\", id)\n\t}\n\n\tvalue := \"\"\n\tif nil != sortMode {\n\t\tvalue = strconv.Itoa(*sortMode)\n\t}\n\tif tree.Root.IALAttr(DocSortModeAttr) != value {\n\t\tif err = setNodeAttrs(tree.Root, tree, map[string]string{DocSortModeAttr: value}); nil != err {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\teffectiveSortMode, resolveErr := ResolveDocTreeSortMode(tree.Box, tree.Path)\n\tif nil != resolveErr {\n\t\treturn nil, resolveErr\n\t}\n\tret = &DocSortModeResult{\n\t\tBox:               tree.Box,","sourceCodeStart":2472,"sourceCodeEnd":2508,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/kernel/model/file.go#L2472-L2508","documentation":"SetDocSortMode guard: the block ID resolved to a tree, but the block is not the document root (tree.ID != id or the node is not NodeDocument). Only a document can declare a child-document sort mode; passing a child block's ID triggers this error.","triggerScenarios":"Thrown at kernel/model/file.go:2490 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass the document ID (root block ID), not a child block ID","Obtain the root ID via the block tree before calling"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"8641553a1f07374001902d3ce773285db1292b2d","analyzedAt":"2026-09-11T16:08:28.414Z","contentChangedAt":"2026-09-11T16:08:28.414Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}