{"record":{"id":"6522fb9cf1084f56","repo":"siyuan-note/siyuan","slug":"read-referenced-attachment-s-w","errorCode":null,"errorMessage":"read referenced attachment [%s]: %w","messagePattern":"read referenced attachment \\[(.+?)\\]: %w","errorType":"exception","errorClass":"obsidianUserError","httpStatus":null,"severity":"error","filePath":"kernel/model/import_obsidian.go","lineNumber":541,"sourceCode":"\tprogress(35, \"Analyzing Markdown syntax\")\n\tif err = analyzeObsidianDocuments(ctx, ret, progress); err != nil {\n\t\treturn nil, err\n\t}\n\tret.Analysis.MarkdownCount = countObsidianSourceDocs(ret.Docs)\n\tvar assetKeys []string\n\tfor key := range ret.Assets {\n\t\tassetKeys = append(assetKeys, key)\n\t}\n\tsort.Strings(assetKeys)\n\tfor _, key := range assetKeys {\n\t\tif err = ctx.Err(); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tasset := ret.Assets[key]\n\t\tif err = validateObsidianReadableFile(asset.Source); err != nil {\n\t\t\tif ret.ReferencedAssets[key] != nil {\n\t\t\t\treturn nil, newObsidianUserError(348, asset.Source.RelPath,\n\t\t\t\t\tfmt.Errorf(\"read referenced attachment [%s]: %w\", asset.Source.RelPath, err))\n\t\t\t}\n\t\t\tret.Analysis.Warnings = append(ret.Analysis.Warnings, asset.Source.RelPath)\n\t\t\tcontinue\n\t\t}\n\t\tret.ImportAssets[key] = asset\n\t\tret.Analysis.ImportableAssetCount++\n\t\tret.Analysis.ImportableAssetSize += asset.Source.Size\n\t}\n\tret.Analysis.UnreferencedFileCount = len(ret.ImportAssets) - len(ret.ReferencedAssets)\n\tif ret.Analysis.UnreferencedFileCount < 0 {\n\t\tret.Analysis.UnreferencedFileCount = 0\n\t}\n\tprogress(100, \"Analysis completed\")\n\treturn ret, nil\n}\n\nfunc validateObsidianVaultRoot(localPath string) (string, error) {\n\tif strings.TrimSpace(localPath) == \"\" {","sourceCodeStart":523,"sourceCodeEnd":559,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/import_obsidian.go#L523-L559","documentation":"During Obsidian asset collection, validateObsidianReadableFile failed for an asset that is referenced by notes, so the import aborts with a wrapped error ('read referenced attachment [%s]: %w') carrying the i18n 348 message ('Unable to import asset file [%s]') plus the underlying cause. Unreferenced assets only produce a warning instead.","triggerScenarios":"Running the vault import when a note-referenced attachment cannot be opened/read: file deleted or moved since analysis, permission denied, name too long, locked by another process, or invalid characters in the path.","commonSituations":"Vault synced incompletely (empty attachment stubs), OneDrive/ iCloud placeholder files not downloaded, Windows permission or path-length issues, attachments excluded by sync tools.","solutions":["Open the reported attachment path in Obsidian/file manager to confirm it exists and is readable, then re-run the import","Fix OS-level causes: download cloud-placeholder files, grant read permission, shorten the path","Remove or repair the broken link in the note if the attachment is truly gone, then re-import","If the file is intentionally absent, mark it as unreferenced (remove references) so the import degrades to a warning"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"for (const a of referencedAssets) {\n  await fs.promises.access(a.path, fs.constants.R_OK).catch(() => { preflightFailures.push(a.relPath); });\n}\nif (preflightFailures.length) reportAndFix(preflightFailures);","typeGuard":null,"tryCatchPattern":"try { await importVault(path); } catch (e) { const m = /read referenced attachment \\[(.+?)\\]/.exec(String(e)); if (m) fixOrUnreferenceAsset(m[1]); else throw e; }","preventionTips":["Preflight-check every referenced attachment for readability before importing","Fully download cloud-placeholder (OneDrive/iCloud) files first","Repair or remove broken attachment links in Obsidian before import"],"tags":["obsidian","import","file-read","attachment"],"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"}