siyuan-note/siyuan · error
removed created document snapshot is missing
Error message
removed created document snapshot is missing
What it means
During rollback/undo handling of template-created documents, the kernel removes the previously created document via removeCreatedDoc, which must return the removed tree so it can be recorded in attemptedRemovedDocs. If removal reports success but returns a nil tree, the kernel's internal invariant is broken and it fails with this error instead of proceeding with a missing snapshot.
Source
Thrown at kernel/model/transaction.go:2680
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 8641553a1f)
Solutions
- Refresh/reindex the notebook so disk state and index agree, then retry the rollback/undo
- Check whether the document was already deleted by another client or sync; if so, skip the stale undo operation
- Inspect kernel logs around removeCreatedDoc to determine why a successful removal produced no tree; report as a kernel bug if reproducible from normal flows
Defensive patterns
Strategy: retry
Validate before calling
const docExists = await fetchPost('/api/filetree/getDoc', {id: createdDocId});
if (docExists.code === 0) throw new Error('doc already removed elsewhere'); Try / catch
try {
await undoTemplateCreation(createdDocId);
} catch (e) {
if (String(e.message).includes('removed created document snapshot is missing')) {
await reindexNotebook(boxId);
await undoTemplateCreation(createdDocId); // retry once after refresh
} else { throw e; }
} Prevention
- Avoid concurrent deletion of the same generated document from multiple clients
- Keep the index consistent with disk (refresh after external file changes)
- Report reproducible occurrences; success-with-nil-tree indicates an internal defect
When it happens
Trigger: Commit path where a created doc is being removed (undo of template creation) and removeCreatedDoc(box, tree.Path, lute) returns (nil, nil) — an unexpected internal result, e.g. the remove implementation found nothing to snapshot despite no error.
Common situations: Concurrent deletion of the same created document by another client between creation and rollback; index/disk disagreement so removal succeeds logically but cannot produce the tree; a bug in the pluggable removeCreatedDoc implementation.
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
- template document tree parent snapshot is invalid
- invalid created doc compensation snapshot
- install local marketplace package failed: %w; rollback faile
- install marketplace package failed: %w; rollback failed: %s
- %w; cleanup failed: %v
AI-assisted analysis of siyuan-note/siyuan@8641553a1f (2026-09-11).
Data as JSON: /api/errors/03f2e5c69492807e.
Report an issue: GitHub.