siyuan-note/siyuan · error

removed created document snapshot is missing

Error message

removed created document snapshot is missing

What it means

When a template-created document must be rolled back, removeCreatedDoc deletes it and is expected to return the removed tree. A nil tree with no error is treated as a broken compensation step — the code cannot record the removed document in attemptedRemovedDocs without its snapshot, so the rollback aborts with this error.

Solutions

  1. Inspect removeCreatedDoc to see why it returned nil despite no error
  2. Check whether the created doc was already deleted by another process before rollback
  3. Re-run transaction rollback after refreshing the notebook state
  4. Rebuild the index to reconcile disk and blocktree state
Defensive patterns

Strategy: try-catch

Type guard

func hasRemovedTree(t *parse.Tree) bool { return t != nil }

Try / catch

if err := rollback(); err != nil && strings.Contains(err.Error(), "removed created doc snapshot is missing") { refreshBoxDocInfo(); retryRollback() }

Prevention

When it happens

Trigger: Calling the compensation/undo path where removeCreatedDoc(box, tree.Path, lute) succeeds but returns nil — the removal routine did not return the deleted tree snapshot as its contract requires.

Common situations: Internal invariant breakage in the removal path (document already gone so nothing meaningful to return); partially failed transaction compensation; disk state diverging from the in-memory trees.

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


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

Appendix: source

Thrown at kernel/model/transaction.go:2768

	for _, tree := range tx.removedTemplateCreatedDocs {
		if nil == tree {
			continue
		}
		attemptedRemovedDocs = append(attemptedRemovedDocs, tree)
		box := Conf.Box(tree.Box)
		if nil == box {
			return ErrBoxNotFound
		}
		removeCreatedDoc := tx.removeCreatedDoc
		if nil == removeCreatedDoc {
			removeCreatedDoc = removeDoc
		}
		removedTree, removeErr := removeCreatedDoc(box, tree.Path, util.NewLute())
		if nil != removeErr {
			return removeErr
		}
		if nil == removedTree {
			return errors.New("removed created document snapshot is missing")
		}
		attemptedRemovedDocs[len(attemptedRemovedDocs)-1] = removedTree
		refreshBoxDocInfo(removedTree)
	}

	var orderedTrees []*parse.Tree
	restoredIDs := map[string]struct{}{}
	for _, tree := range tx.restoredTemplateCreatedDocs {
		if nil == tree {
			continue
		}
		if current := tx.trees[tree.ID]; nil != current {
			orderedTrees = append(orderedTrees, current)
			restoredIDs[tree.ID] = struct{}{}
		}
	}
	for id, tree := range tx.trees {
		if _, restored := restoredIDs[id]; !restored {

View on GitHub (pinned to 9f775e8a12)