siyuan-note/siyuan · error

created doc path [ ] already exists

Error message

created doc path [%s] already exists

What it means

During transaction commit compensation, each tree flagged as restored (present in restoredIDs) is re-written, but only if its target path is free. If the path the created doc would occupy already exists on disk, proceeding would overwrite an existing document, so the commit aborts with the offending path in the message.

Solutions

  1. Remove or rename the existing document at the reported path, then retry
  2. Delete the leftover doc from the failed prior attempt (same ID/content)
  3. Change the new document's name so its path is unique
  4. Inspect data/<box>/ to confirm the leftover file before deleting
Defensive patterns

Strategy: validation

Validate before calling

if box.Exist(tree.Path) { /* rename target or clean up leftover doc before committing */ }

Try / catch

if err := tx.Commit(); err != nil && strings.Contains(err.Error(), "already exists") { cleanupLeftoverDoc(path); retry() }

Prevention

When it happens

Trigger: Replaying/retrying a transaction that already created the document in a prior (partially applied) attempt, so box.Exist(tree.Path) is true for a restored tree ID.

Common situations: A previous transaction attempt crashed after creating the doc but before completing; manual creation of a document with the same path; sync restored a doc at the same path before the retry.

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


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

Appendix: source

Thrown at kernel/model/transaction.go:2813

			op.Data = nil
		}
	}
	for _, op := range tx.UndoOperations {
		if _, ok := op.Data.(*parse.Tree); ok {
			if nil == op.Tree {
				op.Tree = op.Data.(*parse.Tree)
			}
			op.Data = nil
		}
	}
	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 9f775e8a12)