{"record":{"id":"5f439dbda5f7bfa6","repo":"siyuan-note/siyuan","slug":"w-read-vault-config-directory-v","errorCode":null,"errorMessage":"%w: read Vault config directory: %v","messagePattern":"%w: read Vault config directory: (.+?)","errorType":"exception","errorClass":"errObsidianVaultUnreadable","httpStatus":null,"severity":"error","filePath":"kernel/model/import_obsidian.go","lineNumber":589,"sourceCode":"\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\n\t}\n\tentries, err := os.ReadDir(absDir)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"read Vault directory [%s]: %w\", relDir, err)\n\t}\n\tsort.Slice(entries, func(i, j int) bool { return strings.ToLower(entries[i].Name()) < strings.ToLower(entries[j].Name()) })\n\tfor _, entry := range entries {\n\t\tif err = ctx.Err(); err != nil {","sourceCodeStart":571,"sourceCodeEnd":607,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/import_obsidian.go#L571-L607","documentation":"os.Lstat on the vault's `.obsidian` configuration directory failed with an error other than NotExist, so the importer cannot determine whether the selected directory is a real Obsidian Vault. It is wrapped in errObsidianVaultUnreadable to signal an environment/OS-level failure rather than a missing-config condition.","triggerScenarios":"validateObsidianVaultRoot calls os.Lstat(filepath.Join(abs, \".obsidian\")) and statErr is neither nil nor os.IsNotExist — e.g. EACCES (parent dir not searchable), ELOOP (symlink loop), ENOTDIR (`.obsidian` exists as a path component over a file on some systems).","commonSituations":"Vault directory has restrictive Unix permissions (e.g. another user's home directory); filesystem mounted with no access; Windows ACLs denying traversal; a broken link cycle named `.obsidian`.","solutions":["Fix permissions on the Vault directory so the SiYuan process can traverse it (chmod/chown or grant read access)","Check for symlink loops or unusual files named `.obsidian` and remove/repair them","Run SiYuan under a user account that can access the Vault location","If the directory genuinely has no readable `.obsidian`, move the Vault to an accessible location"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const fs = require('fs');\ntry { fs.accessSync(require('path').join(vaultPath, '.obsidian'), fs.constants.R_OK); } catch (e) {\n  if (e.code !== 'ENOENT') console.error('cannot stat .obsidian:', e.message);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Verify the SiYuan process can read the vault directory before starting an import","Avoid vaults under other users' home directories or restricted mounts","Check for symlink loops in the vault root"],"tags":["obsidian-import","filesystem","permissions","stat"],"backgroundTag":"file-read-failed","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"}