siyuan-note/siyuan · error

template document tree plan contains an unsupported parent…

Error message

template document tree plan contains an unsupported parent operation

What it means

Each do-operation's Action must be in the inverseActions whitelist (insert, delete, update, foldHeading, unfoldHeading, setAttrs) and its RootID must be empty. Actions without a defined inverse or root-scoped operations (non-empty RootID) cannot participate in the plan's reversibility accounting and are rejected as unsupported. The inverse action name is subsequently used to find the matching undo operation.

Solutions

  1. Restrict parent transaction operations to the whitelisted block-level actions
  2. Ensure RootID is empty on parent do operations; run root-level work in a separate transaction
  3. Update inverseActions in validateTemplateDocTreeParentOperations if a new action legitimately needs support

Example fix

// before
do := &Operation{Action: "moveBlock", ID: id, RootID: rootID}
// after
do := &Operation{Action: "update", ID: id}
Defensive patterns

Strategy: validation

Validate before calling

supported := map[string]bool{"insert": true, "delete": true, "update": true, "foldHeading": true, "unfoldHeading": true, "setAttrs": true}
for _, op := range tx.DoOperations {
    if !supported[op.Action] || op.RootID != "" {
        return errors.New("unsupported do action: " + op.Action)
    }
}

Prevention

When it happens

Trigger: Attaching a plan to a transaction whose DoOperations include an action outside the whitelist (e.g. moveBlock, append, plugin-defined actions) or a do operation with a non-empty RootID field.

Common situations: Combining template doc-tree attachment with root/document-level operations; frontend sending newer action types not yet mirrored in the kernel's inverse map; synthetic test transactions setting RootID.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


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

Appendix: source

Thrown at kernel/model/template_doc_tree.go:554

	undoOperations := map[string]int{}
	for _, operation := range transaction.UndoOperations {
		if nil == operation || "" == operation.ID {
			return errors.New("template document tree plan contains an invalid parent undo operation")
		}
		if _, supported := inverseActions[operation.Action]; !supported || "" != operation.RootID {
			return errors.New("template document tree plan contains an unsupported parent undo operation")
		}
		undoOperations[operation.Action+"\x00"+operation.ID]++
	}

	hasContentMutation := false
	for _, operation := range transaction.DoOperations {
		if nil == operation || "" == operation.ID {
			return errors.New("template document tree plan contains an invalid parent operation")
		}
		inverseAction, supported := inverseActions[operation.Action]
		if !supported || "" != operation.RootID {
			return errors.New("template document tree plan contains an unsupported parent operation")
		}
		if "insert" == operation.Action || "delete" == operation.Action || "update" == operation.Action {
			hasContentMutation = true
		}
		key := inverseAction + "\x00" + operation.ID
		if 1 > undoOperations[key] {
			return errors.New("template document tree plan parent operations are not reversible")
		}
		undoOperations[key]--
	}
	if !hasContentMutation {
		return errors.New("template document tree plan requires a parent content operation")
	}
	for _, count := range undoOperations {
		if 0 != count {
			return errors.New("template document tree plan parent operations are not reversible")
		}
	}

View on GitHub (pinned to 9f775e8a12)