{"record":{"id":"a1f0b66ccf97b98e","repo":"siyuan-note/siyuan","slug":"345","errorCode":"345","errorMessage":"read Markdown [%s]: %w","messagePattern":"read Markdown \\[(.+?)\\]: %w","errorType":"error_code","errorClass":"newObsidianUserError","httpStatus":null,"severity":"error","filePath":"kernel/model/import_obsidian.go","lineNumber":953,"sourceCode":"\tif err != nil {\n\t\treturn nil, err\n\t}\n\tafter, err := os.Stat(file.AbsPath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif before.Size() != after.Size() || !before.ModTime().Equal(after.ModTime()) {\n\t\treturn nil, fmt.Errorf(\"%w while reading\", errObsidianSourceChanged)\n\t}\n\treturn data, nil\n}\n\nfunc newObsidianReadUserError(file *obsidianSourceFile, err error) error {\n\tlanguage := 345\n\tif errors.Is(err, errObsidianSourceChanged) {\n\t\tlanguage = 346\n\t}\n\treturn newObsidianUserError(language, file.RelPath, fmt.Errorf(\"read Markdown [%s]: %w\", file.RelPath, err))\n}\n\nfunc validateObsidianReadableFile(file *obsidianSourceFile) error {\n\topened, err := os.Open(file.AbsPath)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer opened.Close()\n\tbuffer := make([]byte, 1)\n\t_, err = opened.Read(buffer)\n\tif err != nil && !errors.Is(err, io.EOF) {\n\t\treturn err\n\t}\n\treturn validateObsidianSourceMetadata(file)\n}\n\nfunc buildObsidianHeadingIndex(doc *obsidianDocPlan, tree *parse.Tree) {\n\tstack := make([]string, 6)","sourceCodeStart":935,"sourceCodeEnd":971,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/kernel/model/import_obsidian.go#L935-L971","documentation":"This error wraps a failure to read an Obsidian vault Markdown file during import. The kernel opens each analyzed .md file to stage its content; if the file cannot be opened or its content changed since analysis (errObsidianSourceChanged maps to language 346), a user-facing localized error is produced with the file's relative path.","triggerScenarios":"os.Open fails on file.AbsPath during validateObsidianReadableFile (file deleted, permission denied, path too long), or the file's size/mtime metadata differs from what was recorded during analysis (errObsidianSourceChanged).","commonSituations":"Vault edited or synced (Syncthing/iCloud/OneDrive) while the import is running; files moved or renamed in the vault between analysis and staging; read-protected files; a locked file on Windows opened by another program.","solutions":["Close apps syncing the vault and re-run the import so analysis and staging see a stable snapshot","Verify the file at the reported relative path still exists and is readable (check permissions, open it in an editor)","Re-run the import without modifying the vault while it runs; if it persists, copy the vault to a local folder and import from there"],"exampleFix":"// before: importing directly from a synced cloud vault\nimportObsidian(\"C:/Users/me/OneDrive/Obsidian/MyVault\")\n// after: pause sync, or import from a stable local copy\n// copy MyVault to D:/tmp/MyVault, then:\nimportObsidian(\"D:/tmp/MyVault\")","handlingStrategy":"validation","validationCode":"const fs = require('fs');\nfunction assertReadable(absPath) {\n  const fd = fs.openSync(absPath, 'r');\n  fs.closeSync(fd);\n}\n// call for each vault .md file before starting the import\nfiles.forEach(f => assertReadable(f.absPath));","typeGuard":null,"tryCatchPattern":"try { await apiImportObsidian(vaultPath); }\ncatch (e) {\n  if (/read Markdown \\[/.test(e.msg)) {\n    console.error('Unreadable vault file:', e.msg); // fix permissions/restore file, retry\n  }\n}","preventionTips":["Pause cloud sync (Syncthing/iCloud/OneDrive) for the vault during import","Copy the vault to a local stable folder and import the copy","Check file permissions on the vault before starting","Close Obsidian and other editors that may lock files"],"tags":["file-read-failed","obsidian-import","filesystem"],"backgroundTag":"file-read-failed","analyzedSha":"8641553a1f07374001902d3ce773285db1292b2d","analyzedAt":"2026-09-11T16:08:28.414Z","contentChangedAt":"2026-09-11T16:08:28.414Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}