siyuan-note/siyuan · error · errObsidianVaultUnsafePath
: Vault root and SiYuan workspace contain each other
Error message
%w: Vault root and SiYuan workspace contain each other
What it means
The Obsidian Vault root selected for import is rejected because it overlaps with the SiYuan workspace directory: the vault equals the workspace, sits inside it, or contains it. Importing in that configuration would let the importer write/scan into SiYuan's own internal data, corrupting the workspace. The check is wrapped in errObsidianVaultUnsafePath so callers can test with errors.Is.
Solutions
- Choose an Obsidian Vault directory located outside the SiYuan workspace directory
- If the vault currently lives inside the workspace, move it out to a separate path before importing
- If the workspace lives inside a notes folder, move the workspace or import only a subfolder of the vault
- Verify the resolved absolute path with filepath.Abs/filepath.Clean — symlinks or relative paths may unexpectedly resolve inside the workspace
Example fix
// before vaultRoot := util.WorkspaceDir // workspace itself — rejected // after vaultRoot := "/home/user/Documents/MyVault" // separate directory outside the workspace
Defensive patterns
Strategy: validation
Validate before calling
const abs = require('path').resolve(require('path').clean(vaultPath));
const workspace = require('path').resolve(siYuanWorkspaceDir);
if (abs === workspace || abs.startsWith(workspace + require('path').sep) || workspace.startsWith(abs + require('path').sep)) {
throw new Error('Vault must be outside the SiYuan workspace');
} Prevention
- Keep Obsidian vaults in a directory disjoint from the SiYuan workspace
- Resolve symlinks before choosing the vault path so the effective path is known
- Never configure the import target by copying the workspace path
When it happens
Trigger: Calling the Obsidian import API (validateObsidianVaultRoot path) with a vault path that: is exactly filepath.Clean(util.WorkspaceDir), is a subdirectory of the workspace (e.g. workspace/data/my-vault), or is a parent directory of the workspace.
Common situations: Users point the import dialog at the SiYuan workspace folder itself (thinking their notes are there), or keep an Obsidian vault nested inside the workspace, or place the workspace inside an existing vault-like notes directory.
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
- 345
- can not open file, just support open folder only
- can not remove [ ] caused by it is not a dir
- dir [ ] has more than 1 file:\n
- Export failed
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/45bbcf754091fa2d.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/model/import_obsidian.go:581
if err != nil {
return "", fmt.Errorf("%w: normalize Vault path: %v", errObsidianVaultUnreadable, err)
}
info, err := os.Lstat(abs)
if err != nil {
return "", fmt.Errorf("%w: read Vault root: %v", errObsidianVaultUnreadable, err)
}
if !info.IsDir() {
return "", errObsidianVaultNotDirectory
}
if info.Mode()&os.ModeSymlink != 0 || isObsidianResolvedLink(abs) {
return "", fmt.Errorf("%w: Vault root is a symbolic link or reparse point", errObsidianVaultUnsafePath)
}
if util.IsSensitivePath(abs) {
return "", fmt.Errorf("%w: selected Vault path is sensitive", errObsidianVaultUnsafePath)
}
workspace, _ := filepath.Abs(filepath.Clean(util.WorkspaceDir))
if sameObsidianPath(abs, workspace) || gulu.File.IsSubPath(workspace, abs) || gulu.File.IsSubPath(abs, workspace) {
return "", fmt.Errorf("%w: Vault root and SiYuan workspace contain each other", errObsidianVaultUnsafePath)
}
configPath := filepath.Join(abs, ".obsidian")
configInfo, statErr := os.Lstat(configPath)
if statErr != nil {
if os.IsNotExist(statErr) {
return "", errObsidianVaultConfigMissing
}
return "", fmt.Errorf("%w: read Vault config directory: %v", errObsidianVaultUnreadable, statErr)
}
if !configInfo.IsDir() || configInfo.Mode()&os.ModeSymlink != 0 || isObsidianResolvedLink(configPath) {
return "", errObsidianVaultConfigMissing
}
return abs, nil
}
func scanObsidianVaultFiles(ctx context.Context, vault *obsidianVaultContext, relDir, absDir string) error {
if err := ctx.Err(); err != nil {
return errView on GitHub (pinned to 9f775e8a12)