{"record":{"id":"45bbcf754091fa2d","repo":"siyuan-note/siyuan","slug":"w-vault-root-and-siyuan-workspace-contain-each-o","errorCode":null,"errorMessage":"%w: Vault root and SiYuan workspace contain each other","messagePattern":"%w: Vault root and SiYuan workspace contain each other","errorType":"exception","errorClass":"errObsidianVaultUnsafePath","httpStatus":null,"severity":"error","filePath":"kernel/model/import_obsidian.go","lineNumber":581,"sourceCode":"\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"%w: normalize Vault path: %v\", errObsidianVaultUnreadable, err)\n\t}\n\tinfo, err := os.Lstat(abs)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"%w: read Vault root: %v\", errObsidianVaultUnreadable, err)\n\t}\n\tif !info.IsDir() {\n\t\treturn \"\", errObsidianVaultNotDirectory\n\t}\n\tif info.Mode()&os.ModeSymlink != 0 || isObsidianResolvedLink(abs) {\n\t\treturn \"\", fmt.Errorf(\"%w: Vault root is a symbolic link or reparse point\", errObsidianVaultUnsafePath)\n\t}\n\tif util.IsSensitivePath(abs) {\n\t\treturn \"\", fmt.Errorf(\"%w: selected Vault path is sensitive\", errObsidianVaultUnsafePath)\n\t}\n\tworkspace, _ := filepath.Abs(filepath.Clean(util.WorkspaceDir))\n\tif sameObsidianPath(abs, workspace) || gulu.File.IsSubPath(workspace, abs) || gulu.File.IsSubPath(abs, workspace) {\n\t\treturn \"\", fmt.Errorf(\"%w: Vault root and SiYuan workspace contain each other\", errObsidianVaultUnsafePath)\n\t}\n\tconfigPath := filepath.Join(abs, \".obsidian\")\n\tconfigInfo, statErr := os.Lstat(configPath)\n\tif statErr != nil {\n\t\tif os.IsNotExist(statErr) {\n\t\t\treturn \"\", errObsidianVaultConfigMissing\n\t\t}\n\t\treturn \"\", fmt.Errorf(\"%w: read Vault config directory: %v\", errObsidianVaultUnreadable, statErr)\n\t}\n\tif !configInfo.IsDir() || configInfo.Mode()&os.ModeSymlink != 0 || isObsidianResolvedLink(configPath) {\n\t\treturn \"\", errObsidianVaultConfigMissing\n\t}\n\treturn abs, nil\n}\n\nfunc scanObsidianVaultFiles(ctx context.Context, vault *obsidianVaultContext, relDir, absDir string) error {\n\tif err := ctx.Err(); err != nil {\n\t\treturn err","sourceCodeStart":563,"sourceCodeEnd":599,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/import_obsidian.go#L563-L599","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nvaultRoot := util.WorkspaceDir // workspace itself — rejected\n// after\nvaultRoot := \"/home/user/Documents/MyVault\" // separate directory outside the workspace","handlingStrategy":"validation","validationCode":"const abs = require('path').resolve(require('path').clean(vaultPath));\nconst workspace = require('path').resolve(siYuanWorkspaceDir);\nif (abs === workspace || abs.startsWith(workspace + require('path').sep) || workspace.startsWith(abs + require('path').sep)) {\n  throw new Error('Vault must be outside the SiYuan workspace');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["obsidian-import","filesystem","path-safety","workspace"],"backgroundTag":"path-traversal-blocked","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}