{"record":{"id":"94c3330fa929c49d","repo":"siyuan-note/siyuan","slug":"target-asset-does-not-exist-locally-s","errorCode":null,"errorMessage":"target asset does not exist locally: %s","messagePattern":"target asset does not exist locally: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/asset_relink.go","lineNumber":274,"sourceCode":"\t\t\treturn \"\", err\n\t\t}\n\t\trealRoot, err := filepath.EvalSymlinks(root)\n\t\tif err != nil || !gulu.File.IsSubPath(realRoot, real) {\n\t\t\treturn \"\", fmt.Errorf(\"asset escapes its directory: %s\", assetPath)\n\t\t}\n\t\tif err = validateRelinkStoragePath(real); err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t\tif IsEncryptedAssetPath(real) {\n\t\t\treturn \"\", errors.New(\"encrypted assets are not supported\")\n\t\t}\n\t\tif found != \"\" && found != candidate {\n\t\t\treturn \"\", fmt.Errorf(\"ambiguous asset path: %s\", assetPath)\n\t\t}\n\t\tfound = candidate\n\t}\n\tif required && found == \"\" {\n\t\treturn \"\", fmt.Errorf(\"target asset does not exist locally: %s\", assetPath)\n\t}\n\treturn found, nil\n}\n\nfunc (p *assetRelinkPlan) scanViews() error {\n\tdir := filepath.Join(util.DataDir, \"storage\", \"av\")\n\tif err := p.observe(dir); err != nil {\n\t\treturn err\n\t}\n\tentries, err := os.ReadDir(dir)\n\tif err != nil && !os.IsNotExist(err) {\n\t\treturn err\n\t}\n\tfor _, entry := range entries {\n\t\tif err := p.checkContext(); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tid := strings.TrimSuffix(entry.Name(), \".json\")","sourceCodeStart":256,"sourceCodeEnd":292,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/asset_relink.go#L256-L292","documentation":"resolveRelinkAsset requires that a referenced asset exists locally when the required flag is set. If none of the asset roots contain a regular file matching the reference path, the relink scan fails because there is no local file to relink to or to verify.","triggerScenarios":"A document references 'assets/missing.png' but no notebook asset root contains assets/missing.png; scanMetadata calls resolveRelinkAsset with required=true during relink preflight.","commonSituations":"Assets were deleted or not synced to this device; the workspace was restored from a partial backup; on-demand asset download has not fetched the file yet; the reference was hand-edited to a wrong path.","solutions":["Place the missing asset file at the referenced path under one of the asset roots","Re-sync the workspace so the referenced asset is downloaded to this device","Fix the reference path in the document if it points to a wrong/renamed asset","Remove the stale reference if the asset is no longer needed"],"exampleFix":"// before\n// document references assets/old-name.png, file missing locally\n// after\n// copy the file into place:\nos.Rename(\"downloads/old-name.png\", filepath.Join(nbAssets, \"old-name.png\"))","handlingStrategy":"validation","validationCode":"// verify the asset exists locally before triggering a relink\nfunc assetExists(roots []string, assetPath string) bool {\n\tfor _, root := range roots {\n\t\tif _, err := os.Stat(filepath.Join(root, strings.TrimPrefix(assetPath, \"assets/\"))); err == nil {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}","typeGuard":null,"tryCatchPattern":"// wrap the relink scan to surface missing-asset errors\nif err := plan.Scan(); err != nil {\n\tif strings.Contains(err.Error(), \"target asset does not exist locally\") {\n\t\t// fetch/sync the asset, then retry\n\t}\n\treturn err\n}","preventionTips":["Fully sync workspaces before relinking so all referenced assets exist locally","Run asset download for referenced assets on devices with on-demand download enabled","Fix or remove broken asset references when documents are moved between notebooks"],"tags":["assets","missing-file","relink","filesystem"],"backgroundTag":"file-not-found","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"}