siyuan-note/siyuan · error
staged document tree contains a symbolic link
Error message
staged document tree contains a symbolic link
What it means
When materializing the staged temporary document tree into the destination notebook, the copy walk rejects any entry that is a symbolic link with 'staged document tree contains a symbolic link'. This prevents symlink attacks and accidental out-of-tree writes during Obsidian import.
Solutions
- Locate and remove/replace the symlink in the staged tree (resolve it to a real file or drop it)
- Re-run the import after cleaning the temp docs directory so staging starts from a clean state
- Keep vault assets on the same filesystem and avoid symlinked attachments in Obsidian
Example fix
// before
if entry.Type()&os.ModeSymlink != 0 {
return errors.New("staged document tree contains a symbolic link")
}
// after: copy the symlink target's content instead of failing
if entry.Type()&os.ModeSymlink != 0 {
resolved, rerr := filepath.EvalSymlinks(current)
if rerr != nil {
return rerr
}
if !isUnder(resolved, stagingRoot) {
return errors.New("staged document tree contains a symbolic link")
}
return filelock.Copy(resolved, destination)
} Defensive patterns
Strategy: validation
Validate before calling
err := filepath.WalkDir(stagingRoot, func(p string, d fs.DirEntry, err error) error {
if err == nil && d.Type()&os.ModeSymlink != 0 {
return fmt.Errorf("symlink found at %s", p)
}
return err
}) Prevention
- Avoid symlinked files in the Obsidian vault
- Clean the temp docs directory before each import
- Extract archives with symlink preservation disabled
When it happens
Trigger: The staged tree directory (or an Obsidian-side file carried into it) contains an entry whose type has `os.ModeSymlink` set at copy time, causing `filepath.WalkDir`'s copy step to return this error.
Common situations: The Obsidian vault or temp directory contains symlinks created by Unix tools; an attacker-planted symlink in a shared temp directory; package extraction preserved symlinks.
Understand the failure class
Background: Path traversal blocked: "path escapes the workspace" and "outside site root" errors when a path will not stay inside its allowed directory — this error's family across 26 libraries.
Related errors
- archive entry resolves outside destination
- asset path resolves outside assets directory
- asset path resolves outside notebook assets directory
- child template path is outside the current template package
- marketplace package contains an unsupported file
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/55f376f4c9565a09.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/model/import_obsidian.go:2437
func copyObsidianTreeFiles(sourceRoot, destinationRoot string) error {
return filepath.WalkDir(sourceRoot, func(current string, entry fs.DirEntry, walkErr error) error {
if walkErr != nil {
return walkErr
}
rel, err := filepath.Rel(sourceRoot, current)
if err != nil {
return err
}
if rel == "." {
return nil
}
destination := filepath.Join(destinationRoot, rel)
if entry.IsDir() {
return os.MkdirAll(destination, 0755)
}
if entry.Type()&os.ModeSymlink != 0 {
return errors.New("staged document tree contains a symbolic link")
}
return filelock.Copy(current, destination)
})
}
func availableObsidianNotebookName(requested string) string {
base := sanitizeObsidianTitle(requested)
existing := map[string]bool{}
boxes, _ := ListNotebooks()
for _, box := range boxes {
existing[strings.ToLower(box.Name)] = true
}
if !existing[strings.ToLower(base)] {
return base
}
for index := 2; ; index++ {
candidate := fmt.Sprintf("%s (%d)", base, index)
if !existing[strings.ToLower(candidate)] {View on GitHub (pinned to 9f775e8a12)