siyuan-note/siyuan · error

attribute [ ] is only supported on regular document roots

Error message

attribute [%s] is only supported on regular document roots

What it means

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.

Solutions

  1. Only send the sort-mode attribute for the document root id of a regular notebook document
  2. Skip the DocSortModeAttr key for non-document blocks in batch writes
  3. Verify node type first via /api/block/getBlockInfo (root_id / rootID) and use the rootID
  4. Do not attempt this attribute on box-doc/encrypted special documents

Example fix

// before
await fetchPost('/api/attr/setBlockAttrs', {id: blockId, attrs: {[DOC_SORT_MODE]: '1'}});
// after
const info = (await fetchSyncPost('/api/block/getBlockInfo', {id: blockId})).data;
if (info.rootID === info.id && !isBoxDoc(info.box, info.id)) {
  await fetchPost('/api/attr/setBlockAttrs', {id: info.rootID, attrs: {[DOC_SORT_MODE]: '1'}});
}
Defensive patterns

Strategy: validation

Validate before calling

const info = (await fetchSyncPost('/api/block/getBlockInfo', {id})).data;
const isDocRoot = info && info.id === info.root_id;

Type guard

function isRegularDocRoot(info) { return !!info && info.id === info.root_id; }

Try / catch

try { await setBlockAttrs(id, attrs); } catch (e) { if (/regular document roots/.test(String(e))) retargetToRoot(id); else throw e; }

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19). Data as JSON: /api/errors/4ef18fc14b7081ed. Report an issue: GitHub.

Appendix: source

Thrown at kernel/model/blockial.go:399

		}
	}

	for name, value := range nameValues {
		value = util.RemoveInvalidRetainCtrl(value)
		value = strings.TrimSpace(value)
		lowerName := strings.ToLower(name)
		// 转换为小写再验证属性名
		if !isValidAttrName(lowerName) {
			err = errors.New(Conf.Language(25) + " [" + node.ID + "]")
			return
		}
		if lowerName == "data-task" {
			err = 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`)
			return
		}
		if DocSortModeAttr == lowerName {
			if ast.NodeDocument != node.Type || IsBoxDoc(boxID, node.ID) {
				err = fmt.Errorf("attribute [%s] is only supported on regular document roots", DocSortModeAttr)
				return
			}
			if "" != value {
				sortMode, parseErr := strconv.Atoi(value)
				if nil != parseErr || !IsValidDocSortMode(sortMode) {
					err = fmt.Errorf("invalid document sort mode [%s]", value)
					return
				}
				value = strconv.Itoa(sortMode)
			}
		}

		// 处理文档标签 https://github.com/siyuan-note/siyuan/issues/13311
		if lowerName == "tags" {
			var tags []string
			tmp := strings.SplitSeq(value, ",")
			for t := range tmp {
				t = strings.TrimSpace(t)

View on GitHub (pinned to 9f775e8a12)