siyuan-note/siyuan · error

template document tree plan contains an unsupported parent…

Error message

template document tree plan contains an unsupported parent undo operation

What it means

validateTemplateDocTreeParentOperations only permits undo operations whose Action has a known inverse (insert, delete, update, foldHeading, unfoldHeading, setAttrs) and whose RootID is empty. An undo action outside this whitelist, or one carrying a RootID (indicating a root-level/document-scoped operation the plan machinery cannot pair), is rejected as unsupported. This keeps the plan attachment restricted to block-level reversible operations.

Solutions

  1. Use only whitelisted actions (insert/delete/update/foldHeading/unfoldHeading/setAttrs) in parent operations
  2. Clear the RootID field on undo operations, or move root-level work into a separate transaction
  3. If a new action must be supported, add it to the inverseActions map in validateTemplateDocTreeParentOperations

Example fix

// before
undo := &Operation{Action: "appendBlock", ID: id, RootID: rootID}
// after
undo := &Operation{Action: "insert", ID: id}
Defensive patterns

Strategy: validation

Validate before calling

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

Prevention

When it happens

Trigger: Attaching a plan to a transaction whose UndoOperations include an action not in inverseActions (e.g. appendBlock, moveBlock, custom plugin actions) or an undo operation with a non-empty RootID field.

Common situations: Plugin or API code attaching template doc-tree plans to transactions containing root-level or document-wide operations; version drift where a new operation action was introduced but not added to the inverse map; testing with synthetic operations that set 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/e4fcf92b8a38d8a5. Report an issue: GitHub.

Appendix: source

Thrown at kernel/model/template_doc_tree.go:542

	return true, nil
}

func validateTemplateDocTreeParentOperations(transaction *Transaction) error {
	inverseActions := map[string]string{
		"insert":        "delete",
		"delete":        "insert",
		"update":        "update",
		"foldHeading":   "unfoldHeading",
		"unfoldHeading": "foldHeading",
		"setAttrs":      "setAttrs",
	}
	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] {

View on GitHub (pinned to 9f775e8a12)