siyuan-note/siyuan · error
asset path contains an unresolved symbolic link
Error message
asset path contains an unresolved symbolic link [%s]
What it means
ResolveAssetPathWithMissingLeaf walks an asset path component by component; when a stat fails with not-exist but Lstat shows the component itself is a symlink, the symlink target cannot be resolved (e.g. dangling or loop), so it fails fast with 'asset path contains an unresolved symbolic link [%s]' naming the offending component. This prevents silently treating a broken symlink as a merely missing file to download.
Solutions
- Inspect the path component named in the error and repair or remove the dangling symlink (ln -sfn to a valid target)
- Remount the drive or re-login to the cloud drive so symlink targets resolve
- Replace symlinks in assets/ with real files if the workspace is synced across devices (SiYuan does not support symlinked asset segments)
- Re-copy the assets directory without symlinks from a backup
Example fix
// shell repair # before: dangling symlink assets/img -> /mnt/usb/photos # /mnt/usb not mounted # after ln -sfn /data/photos assets/img # or copy the real files into assets/img
Defensive patterns
Strategy: validation
Validate before calling
info, err := os.Lstat(assetPath)
if err == nil && info.Mode()&os.ModeSymlink != 0 {
target, lerr := os.Readlink(assetPath)
if lerr != nil { /* skip or repair */ }
if _, serr := os.Stat(target); serr != nil { return fmt.Errorf("dangling symlink %s -> %s", assetPath, target) }
} Try / catch
resolved, err := model.ResolveDataAssetPath(lookupPath)
if err != nil && strings.Contains(err.Error(), "unresolved symbolic link") {
repairOrSkipSymlink(extractPath(err))
} Prevention
- Do not use symlinks inside notebook assets folders, especially in synced workspaces
- Avoid cloud-drive placeholder folders (OneDrive/Dropbox on-demand) as symlinked asset targets
- Audit workspaces after machine migrations with a dangling-symlink scan (find -xtype l)
- Copy real files instead of linking when importing assets from external locations
When it happens
Trigger: Calling ResolveAssetPathWithMissingLeaf (directly or through ResolveDataAssetPath, deferredAssetPathFromFiles, unusedAssetsContainPath) on a workspace data dir where an assets path segment is a symlink whose target does not exist or is unreachable.
Common situations: Workspace synced/restored across machines where absolute or machine-specific symlinks dangle; user replaced an assets folder with a symlink to an unmounted drive; cloud-drive placeholder symlinks (OneDrive/Dropbox on-demand files) that cannot resolve.
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
- asset path resolves outside notebook assets directory
- resolve asset [ ] failed
- asset path resolves outside assets directory
- attribute view definition is not a regular file
- encrypted document is a symbolic link
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/0137a38a822d1b02.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/model/asset_download_read.go:46
)
// ResolveAssetPathWithMissingLeaf 校验尚未下载的路径,已存在的父目录仍须通过符号链接校验。
func ResolveAssetPathWithMissingLeaf(absPath string) (string, error) {
current := filepath.Clean(absPath)
var missing []string
for {
resolved, err := ResolveRealPath(current)
if err == nil {
for i := len(missing) - 1; i >= 0; i-- {
resolved = filepath.Join(resolved, missing[i])
}
return resolved, nil
}
if !os.IsNotExist(err) {
return "", err
}
if info, statErr := os.Lstat(current); statErr == nil && info.Mode()&os.ModeSymlink != 0 {
return "", fmt.Errorf("asset path contains an unresolved symbolic link [%s]", current)
}
parent := filepath.Dir(current)
if parent == current {
return "", err
}
missing = append(missing, filepath.Base(current))
current = parent
}
}
// deferredAssetPath 只解析同步清单,不访问网络,也不以未下载状态推断文件已删除。
func deferredAssetPath(relativePath, boxID string, includeEncrypted bool) (string, error) {
files, err := DeferredSyncAssets()
if err != nil {
return "", err
}
return deferredAssetPathFromFiles(relativePath, boxID, includeEncrypted, files)
}View on GitHub (pinned to 9f775e8a12)