{"record":{"id":"77507ef5c7f9aa0e","repo":"siyuan-note/siyuan","slug":"resolve-asset-s-failed-w","errorCode":null,"errorMessage":"resolve asset [%s] failed: %w","messagePattern":"resolve asset \\[(.+?)\\] failed: %w","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/assets.go","lineNumber":967,"sourceCode":"\tresolvedRoot, evalErr := filepath.EvalSymlinks(assetRoot)\n\tif evalErr != nil {\n\t\terr = fmt.Errorf(\"resolve assets directory [%s] failed: %w\", assetRoot, evalErr)\n\t\treturn\n\t}\n\tif assetDirIndex > 0 {\n\t\tnotebookRoot := filepath.Join(util.DataDir, parts[0])\n\t\tresolvedDataDir, dataEvalErr := filepath.EvalSymlinks(util.DataDir)\n\t\tresolvedNotebookRoot, notebookEvalErr := filepath.EvalSymlinks(notebookRoot)\n\t\tif dataEvalErr != nil || notebookEvalErr != nil ||\n\t\t\t!gulu.File.IsSubPath(resolvedDataDir, resolvedNotebookRoot) ||\n\t\t\t!gulu.File.IsSubPath(resolvedNotebookRoot, resolvedRoot) {\n\t\t\terr = fmt.Errorf(\"notebook asset path resolves outside notebook directory: %s\", assetPath)\n\t\t\treturn\n\t\t}\n\t}\n\tresolvedPath, evalErr := filepath.EvalSymlinks(absPath)\n\tif evalErr != nil {\n\t\terr = fmt.Errorf(\"resolve asset [%s] failed: %w\", absPath, evalErr)\n\t\treturn\n\t}\n\tif !gulu.File.IsSubPath(resolvedRoot, resolvedPath) {\n\t\terr = fmt.Errorf(\"asset path resolves outside assets directory: %s\", assetPath)\n\t\treturn\n\t}\n\n\trelativePath = filepath.ToSlash(dataRelativePath)\n\treturn\n}\n\n// ResolveUnusedDataAssetPath 解析 data 相对资源路径，并确认目标当前未被引用。\nfunc ResolveUnusedDataAssetPath(assetPath string) (relativePath, absPath string, err error) {\n\trelativePath, absPath, err = ResolveDataAssetPath(assetPath)\n\tif err != nil {\n\t\treturn\n\t}\n","sourceCodeStart":949,"sourceCodeEnd":985,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/model/assets.go#L949-L985","documentation":"Thrown by ResolveDataAssetPath (kernel/model/assets.go:967) when filepath.EvalSymlinks fails on the specific asset file's absolute path. Unlike the assets-root errors, this is about the individual file: it fails when the file does not exist, is a broken symlink, or is inaccessible due to permissions.","triggerScenarios":"Calling ResolveDataAssetPath for an asset that was deleted between the time the document referenced it and the time of resolution; resolving a path whose final component is a dangling symlink; resolving a file inside a directory the process cannot read/traverse.","commonSituations":"Stale references in a document after the user deleted the asset from disk; assets removed by an external sync/cleanup tool; a race where the file is being moved; permission mismatch after a user account change.","solutions":["Verify the file at the printed absPath exists: `ls -la <absPath>`.","If deleted, either restore from backup/history or remove the dangling reference from the document.","If it is a broken symlink, recreate the target or remove the link.","Fix read/traverse permissions on the file and its parent directories for the kernel process user."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Verify the asset file exists and is resolvable before calling the resolver, to give a clearer error.\nabs := filepath.Join(util.DataDir, filepath.FromSlash(p))\nif _, err := filepath.EvalSymlinks(abs); err != nil {\n    return fmt.Errorf(\"asset file missing or inaccessible: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"_, absPath, err := model.ResolveDataAssetPath(p)\nif err != nil {\n    if strings.Contains(err.Error(), \"resolve asset [\") {\n        // file-level resolution failure (deleted/dangling link/permissions); guide user to restore or remove reference\n    }\n    return err\n}","preventionTips":["Treat asset references as soft: when a file is missing, offer to remove the broken reference instead of failing hard.","Keep backups/history enabled so deleted assets can be restored.","Avoid concurrent external processes that move/delete assets while the kernel runs."],"tags":["assets","symlinks","filesystem","permissions","missing-file"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}