siyuan-note/siyuan · error
invalid created doc compensation snapshot
Error message
invalid created doc compensation snapshot
What it means
restoreCreatedDocTreeSnapshot is the compensation writer for template-created documents; it requires a fully formed tree with a non-nil Root. A nil tree or a tree missing its root cannot be written via writeTreeUpsertQueue, so the guard rejects it as an invalid compensation snapshot.
Solutions
- Ensure the tree passed in was loaded from disk via LoadTreeByBlockID/LoadTree rather than constructed ad hoc
- Check the code that populates attemptedTemplateCreatedDocs for nil/partial entries
- Re-load the document tree and retry the compensation
- Skip logging-and-skip rather than writing malformed trees if the doc is unrecoverable
Example fix
// before
restoreCreatedDocTreeSnapshot(partialTree) // Root == nil
// after
if tree != nil && tree.Root != nil {
restoreCreatedDocTreeSnapshot(tree)
} Defensive patterns
Strategy: validation
Validate before calling
if tree == nil || tree.Root == nil { return errors.New("cannot restore: incomplete tree") }
restoreCreatedDocTreeSnapshot(tree) Type guard
func restorableTree(t *parse.Tree) bool { return t != nil && t.Root != nil } Try / catch
if err := restoreCreatedDocTreeSnapshot(tree); err != nil && strings.Contains(err.Error(), "invalid created doc compensation snapshot") { reloadTree(); retry() } Prevention
- Only pass trees loaded by LoadTree/LoadTreeByBlockID into compensation code
- Validate tree.Root before storing trees in compensation lists
- Handle failed loads without inserting placeholder trees
- Add tests for compensation with nil and rootless trees
When it happens
Trigger: Transaction compensation calling restoreCreatedDocTreeSnapshot(nil) or with a partially constructed *parse.Tree whose Root was never set — e.g. a tree built from a failed load or a placeholder entry.
Common situations: A prior rollback step stored a nil/partial tree in attemptedTemplateCreatedDocs; corrupted .sy load produced a tree without a root; programming error building the compensation list.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- removed created document snapshot is missing
- a document tree plan must be applied in a single transaction
- attribute view rich text style entity sentinel was not…
- attribute view [ ] template plan not found
- block position changed since conversion
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/891cd89ed830f41a.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/model/transaction.go:2983
}
if restoreErr := restoreCreatedDocTreeSnapshot(tree); nil != restoreErr {
err = errors.Join(err, restoreErr)
continue
}
if box := Conf.Box(tree.Box); nil != box {
box.setSortByConf(path.Dir(tree.Path), tree.ID)
PushCreate(box, tree.Path, nil)
}
}
if nil != tx.templateDocTreeRootSnapshot {
err = errors.Join(err, restoreCreatedDocTreeSnapshot(tx.templateDocTreeRootSnapshot))
}
return
}
func restoreCreatedDocTreeSnapshot(tree *parse.Tree) error {
if nil == tree || nil == tree.Root {
return errors.New("invalid created doc compensation snapshot")
}
if err := writeTreeUpsertQueue(tree); nil != err {
return err
}
treenode.UpsertBlockTree(tree)
return nil
}
func (tx *Transaction) loadTreeByBlockTree(bt *treenode.BlockTree) (ret *parse.Tree, err error) {
if nil == bt {
return nil, ErrBlockNotFound
}
ret = tx.trees[bt.RootID]
if nil != ret {
return
}
View on GitHub (pinned to 9f775e8a12)