{"record":{"id":"4ef18fc14b7081ed","repo":"siyuan-note/siyuan","slug":"attribute-s-is-only-supported-on-regular-docume","errorCode":null,"errorMessage":"attribute [%s] is only supported on regular document roots","messagePattern":"attribute \\[(.+?)\\] is only supported on regular document roots","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/blockial.go","lineNumber":399,"sourceCode":"\t\t}\n\t}\n\n\tfor name, value := range nameValues {\n\t\tvalue = util.RemoveInvalidRetainCtrl(value)\n\t\tvalue = strings.TrimSpace(value)\n\t\tlowerName := strings.ToLower(name)\n\t\t// 转换为小写再验证属性名\n\t\tif !isValidAttrName(lowerName) {\n\t\t\terr = errors.New(Conf.Language(25) + \" [\" + node.ID + \"]\")\n\t\t\treturn\n\t\t}\n\t\tif lowerName == \"data-task\" {\n\t\t\terr = errors.New(`setting or removing [data-task] attribute is not allowed via this interface. Please use \"/api/block/updateTaskListItemMarker\" or \"/api/block/batchUpdateTaskListItemMarker\" to update the task list item marker`)\n\t\t\treturn\n\t\t}\n\t\tif DocSortModeAttr == lowerName {\n\t\t\tif ast.NodeDocument != node.Type || IsBoxDoc(boxID, node.ID) {\n\t\t\t\terr = fmt.Errorf(\"attribute [%s] is only supported on regular document roots\", DocSortModeAttr)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif \"\" != value {\n\t\t\t\tsortMode, parseErr := strconv.Atoi(value)\n\t\t\t\tif nil != parseErr || !IsValidDocSortMode(sortMode) {\n\t\t\t\t\terr = fmt.Errorf(\"invalid document sort mode [%s]\", value)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tvalue = strconv.Itoa(sortMode)\n\t\t\t}\n\t\t}\n\n\t\t// 处理文档标签 https://github.com/siyuan-note/siyuan/issues/13311\n\t\tif lowerName == \"tags\" {\n\t\t\tvar tags []string\n\t\t\ttmp := strings.SplitSeq(value, \",\")\n\t\t\tfor t := range tmp {\n\t\t\t\tt = strings.TrimSpace(t)","sourceCodeStart":381,"sourceCodeEnd":417,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/blockial.go#L381-L417","documentation":"When setting the reserved DocSortModeAttr attribute, setNodeAttrs0 requires the target node to be an ast.NodeDocument and NOT a box-doc (IsBoxDoc false); otherwise it returns 'attribute [%s] is only supported on regular document roots' with the attribute name. Sort mode is stored only on real user document roots, not on synthesized box documents.","triggerScenarios":"POST /api/attr/setBlockAttrs or batchSetBlockAttrs (or other setNodeAttrs0 callers like updateBoundBlockAvsAttribute) with key equal to DocSortModeAttr where the node is a child block instead of a document root, or where the document is a box-doc (IsBoxDoc(boxID, node.ID) true).","commonSituations":"Scripts applying doc sort settings to a block id instead of the doc root id; attempts on encrypted/box-managed pseudo-documents; bulk attr writes that accidentally include the reserved key on every block.","solutions":["Only send the sort-mode attribute for the document root id of a regular notebook document","Skip the DocSortModeAttr key for non-document blocks in batch writes","Verify node type first via /api/block/getBlockInfo (root_id / rootID) and use the rootID","Do not attempt this attribute on box-doc/encrypted special documents"],"exampleFix":"// before\nawait fetchPost('/api/attr/setBlockAttrs', {id: blockId, attrs: {[DOC_SORT_MODE]: '1'}});\n// after\nconst info = (await fetchSyncPost('/api/block/getBlockInfo', {id: blockId})).data;\nif (info.rootID === info.id && !isBoxDoc(info.box, info.id)) {\n  await fetchPost('/api/attr/setBlockAttrs', {id: info.rootID, attrs: {[DOC_SORT_MODE]: '1'}});\n}","handlingStrategy":"validation","validationCode":"const info = (await fetchSyncPost('/api/block/getBlockInfo', {id})).data;\nconst isDocRoot = info && info.id === info.root_id;","typeGuard":"function isRegularDocRoot(info) { return !!info && info.id === info.root_id; }","tryCatchPattern":"try { await setBlockAttrs(id, attrs); } catch (e) { if (/regular document roots/.test(String(e))) retargetToRoot(id); else throw e; }","preventionTips":["Only set sort-mode on the document root id of a regular document","Exclude reserved keys like sort mode from bulk block writes","Resolve rootID via getBlockInfo before writing","Never target box-doc/encrypted pseudo-documents for this attribute"],"tags":["siyuan","doc-sort-mode","reserved-attribute","document-root"],"backgroundTag":"invalid-argument-value","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"}