{"record":{"id":"8c51a3f737a8ffb5","repo":"siyuan-note/siyuan","slug":"query-asset-failed-s","errorCode":null,"errorMessage":"Query asset failed [%s]","messagePattern":"Query asset failed \\[(.+?)\\]","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/assets.go","lineNumber":1155,"sourceCode":"\t\t\tif !gulu.File.IsSubPath(util.WorkspaceDir, realP) {\n\t\t\t\treturn \"\", fmt.Errorf(\"symlink [%s] resolves outside workspace: [%s]\", p, realP)\n\t\t\t}\n\t\t\t// 验证解析后的路径仍在 <boxID>/assets/ 或全局 data/assets/ 下\n\t\t\texpectedPrefix := filepath.Join(util.DataDir, \"assets\")\n\t\t\tif boxID != \"\" {\n\t\t\t\texpectedPrefix = filepath.Join(util.DataDir, boxID, \"assets\")\n\t\t\t}\n\t\t\tif !gulu.File.IsSubPath(expectedPrefix, realP) {\n\t\t\t\treturn \"\", fmt.Errorf(\"symlink [%s] resolves outside assets directory: [%s]\", p, realP)\n\t\t\t}\n\t\t}\n\t\treturn p, nil\n\t}\n\t// 非加密 box 的资源可能回退到全局 data/assets（兼容旧笔记本结构）\n\tif !IsEncryptedBox(boxID) {\n\t\treturn GetAssetAbsPathWithOpt(relativePath, false)\n\t}\n\treturn \"\", fmt.Errorf(Conf.Language(12), relativePath)\n}\n\n// GetAssetAbsPathWithOpt 与 GetAssetAbsPath 一致，但可通过 includeEncrypted 控制是否遍历加密 box。\n// serveAssets 传 true（下游 serveEncryptedAsset 会按锁定状态 fail-closed），其他调用方传 false（安全跳过）。\nfunc GetAssetAbsPathWithOpt(relativePath string, includeEncrypted bool) (string, error) {\n\trelativePath = strings.TrimSpace(relativePath)\n\tif idx := strings.Index(relativePath, \"?\"); idx >= 0 {\n\t\trelativePath = relativePath[:idx]\n\t}\n\n\tabsPath, err := getAssetAbsPath(relativePath, includeEncrypted)\n\tif err == nil && absPath != \"\" {\n\t\treturn absPath, nil\n\t}\n\n\tif err != nil {\n\t\treturn \"\", err\n\t}","sourceCodeStart":1137,"sourceCodeEnd":1173,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/afa823b6b4e4f183511e0bc0a3be93caa94c7c97/kernel/model/assets.go#L1137-L1173","documentation":"GetAssetAbsPathInBox could not find the asset under data/<boxID>/ and the box is encrypted, so the fallback to the global data/assets/ search is skipped - encrypted notebooks are isolation islands whose assets never cross boundaries. The localized 'Query asset failed [<path>]' (Conf.Language(12)) is returned.","triggerScenarios":"Resolving an asset path whose file is missing from an encrypted notebook's assets folder: the file was deleted or moved on disk, the document references a stale path, or the asset actually lives in global data/assets but an encrypted box never falls back to it.","commonSituations":"Manual file cleanup inside data/<boxID>/assets/; sync conflicts that removed files; assets renamed externally so documents keep old paths.","solutions":["Unlock the notebook (Settings - Security) and verify the file exists under data/<boxID>/assets/","Restore the missing file from data/history (File - History) or a sync snapshot","Re-insert the asset into the document so a fresh copy lands in the box's assets folder","If the asset is intentionally global, reference it without the box query parameter"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if model.IsEncryptedBox(boxID) && !filelock.IsExist(filepath.Join(util.DataDir, boxID, relPath)) {\n\t// unresolvable in an encrypted box: offer restore from history instead of calling the API\n}","typeGuard":null,"tryCatchPattern":"A non-nil error here means the asset is genuinely unresolvable in that encrypted box: catch it and render a missing-asset placeholder in the UI rather than retrying or falling back to arbitrary disk locations.","preventionTips":["Do not delete or rename files inside an encrypted notebook's assets folder from the file manager","Use in-app clean/rename operations so references stay consistent","Keep history and sync enabled for encrypted notebooks so removals are recoverable"],"tags":["assets","encrypted-notebook","not-found","i18n"],"backgroundTag":"asset-not-found","analyzedSha":"afa823b6b4e4f183511e0bc0a3be93caa94c7c97","analyzedAt":"2026-08-18T17:04:10.865Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}