{"record":{"id":"ce030393d08256c8","repo":"siyuan-note/siyuan","slug":"template-document-tree-plan-contains-an-unsupporte-ce0303","errorCode":null,"errorMessage":"template document tree plan contains an unsupported parent operation","messagePattern":"template document tree plan contains an unsupported parent operation","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/template_doc_tree.go","lineNumber":554,"sourceCode":"\tundoOperations := map[string]int{}\n\tfor _, operation := range transaction.UndoOperations {\n\t\tif nil == operation || \"\" == operation.ID {\n\t\t\treturn errors.New(\"template document tree plan contains an invalid parent undo operation\")\n\t\t}\n\t\tif _, supported := inverseActions[operation.Action]; !supported || \"\" != operation.RootID {\n\t\t\treturn errors.New(\"template document tree plan contains an unsupported parent undo operation\")\n\t\t}\n\t\tundoOperations[operation.Action+\"\\x00\"+operation.ID]++\n\t}\n\n\thasContentMutation := false\n\tfor _, operation := range transaction.DoOperations {\n\t\tif nil == operation || \"\" == operation.ID {\n\t\t\treturn errors.New(\"template document tree plan contains an invalid parent operation\")\n\t\t}\n\t\tinverseAction, supported := inverseActions[operation.Action]\n\t\tif !supported || \"\" != operation.RootID {\n\t\t\treturn errors.New(\"template document tree plan contains an unsupported parent operation\")\n\t\t}\n\t\tif \"insert\" == operation.Action || \"delete\" == operation.Action || \"update\" == operation.Action {\n\t\t\thasContentMutation = true\n\t\t}\n\t\tkey := inverseAction + \"\\x00\" + operation.ID\n\t\tif 1 > undoOperations[key] {\n\t\t\treturn errors.New(\"template document tree plan parent operations are not reversible\")\n\t\t}\n\t\tundoOperations[key]--\n\t}\n\tif !hasContentMutation {\n\t\treturn errors.New(\"template document tree plan requires a parent content operation\")\n\t}\n\tfor _, count := range undoOperations {\n\t\tif 0 != count {\n\t\t\treturn errors.New(\"template document tree plan parent operations are not reversible\")\n\t\t}\n\t}","sourceCodeStart":536,"sourceCodeEnd":572,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/kernel/model/template_doc_tree.go#L536-L572","documentation":"Every parent DoOperation must use an action from the inverseActions allowlist and have an empty RootID. This error means the forward operation's action cannot be inverted by the plan machinery (e.g. moveBlock, appendBlock) or it carries a RootID, which would conflict with the reserved child-document operations the plan appends (restoreCreatedDoc/removeCreatedDoc).","triggerScenarios":"Submitting a plan transaction containing unsupported parent actions; setting RootID on parent operations; forwarding user edits recorded by other kernel features (which use RootID) into a plan transaction.","commonSituations":"Bulk-edit automation that batches mixed action types into one transaction; porting code from a kernel version where additional actions existed; misunderstanding that RootID here must stay empty for parent ops.","solutions":["Use only insert, delete, update, foldHeading, unfoldHeading, or setAttrs for parent DoOperations","Ensure every parent operation has RootID set to \"\"","Move unrelated or unsupported edits into separate normal transactions","Update the kernel if the needed action should be supported; check the inverseActions map in validateTemplateDocTreeParentOperations"],"exampleFix":"// before\ndoOps := []*Operation{{Action: \"appendBlock\", RootID: rootID, ID: blkID}}\n// after\ndoOps := []*Operation{{Action: \"insert\", ID: blkID, ParentID: parentID}} // supported action, empty RootID","handlingStrategy":"validation","validationCode":"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 != \"\" { reject before submit } }","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"unsupported parent operation\") { split out non-allowlisted actions into separate normal transactions and resubmit }","preventionTips":["Use only insert/delete/update/foldHeading/unfoldHeading/setAttrs for parent ops","Keep RootID empty on every parent operation","Batch only plan-compatible edits into the plan transaction","Consult the kernel's inverseActions map when adding new action types"],"tags":["go","transaction","validation","unsupported-action"],"backgroundTag":"unsupported-operation","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"}