siyuan-note/siyuan · error
created doc path [%s] already exists
Error message
created doc path [%s] already exists
What it means
When restoring documents that were created from a template (e.g. during redo or rollback bookkeeping), the kernel checks that the target path inside the notebook box does not already exist before writing. If a file already occupies tree.Path, writing would clobber an existing document, so the commit fails with this error naming the conflicting path.
Source
Thrown at kernel/model/transaction.go:2709
}
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 {
orderedTrees = append(orderedTrees, tree)
}
}
for _, tree := range orderedTrees {
if _, restored := restoredIDs[tree.ID]; restored {
box := Conf.Box(tree.Box)
if nil == box {
return ErrBoxNotFound
}
if box.Exist(tree.Path) {
return fmt.Errorf("created doc path [%s] already exists", tree.Path)
}
tx.attemptedTemplateCreatedDocs[tree.ID] = tree
}
writeTransactionTree := tx.writeTransactionTree
if nil == writeTransactionTree {
writeTransactionTree = writeTreeUpsertQueue
}
if err = writeTransactionTree(tree); err != nil {
return
}
var sources []any
sources = append(sources, tx)
util.PushSaveDoc(tree.ID, "tx", sources)
checkUpsertInUserGuide(tree)
}
for boxID, icon := range tx.boxIcons {View on GitHub (pinned to 8641553a1f)
Solutions
- Delete or rename the existing document at the reported path, then retry the transaction
- Refresh the document tree so the UI reflects the actual existing document and re-do the template creation into a fresh doc
- Investigate leftover files from a failed prior transaction (compare data/<box>/.siyuan/ contents with the doc tree) and clean them up via the UI
Defensive patterns
Strategy: validation
Validate before calling
const exists = await fetchPost('/api/filetree/docExists', {box: boxId, path: docPath});
if (exists.data) throw new Error('path already exists: ' + docPath); Try / catch
try {
await redoTemplateCreation(tx);
} catch (e) {
if (/created doc path \[.*\] already exists/.test(String(e.message))) {
await reloadDocTree(); // adopt the existing doc instead of recreating it
} else { throw e; }
} Prevention
- Complete undo before starting redo of the same template creation
- Do not manually recreate documents with paths produced by pending transactions
- Refresh the document tree after any failed or interrupted transaction to detect leftovers
When it happens
Trigger: Committing a transaction where a restored/created doc's path already exists in the box (box.Exist(tree.Path) is true) — typically because the document was recreated with the same ID/path earlier, or a prior partial commit left the file behind.
Common situations: Undo followed by redo of template document creation where the first attempt's file was not cleaned up; the same template inserted twice producing the same path; sync restored a copy of the document while a local restore was pending.
Understand the failure class
Background: "already exists" / EEXIST / FileAlreadyExistsException: what the 'file already exists' error means and how to fix it — this error's family across 37 libraries.
Related errors
- load template document tree parent snapshot failed: %w
- template document tree parent snapshot is invalid
- the document used to render the template has changed
- new item templates config is nil
- a document tree plan must be applied in a single transaction
AI-assisted analysis of siyuan-note/siyuan@8641553a1f (2026-09-11).
Data as JSON: /api/errors/df5870dd837c5f7a.
Report an issue: GitHub.