{"record":{"id":"809378207c98fafc","repo":"siyuan-note/siyuan","slug":"s-w-conf-language-382-with-avid","errorCode":null,"errorMessage":"%s: %w (Conf.Language(382) with avID)","messagePattern":"(.+?): %w \\(Conf\\.Language\\(382\\) with avID\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/export.go","lineNumber":2978,"sourceCode":"\t\tlogging.LogErrorf(\"close export .sy.zip failed: %s\", err)\n\t\treturn \"\"\n\t}\n\tif err = os.Rename(zipPartialPath, zipPath); err != nil {\n\t\tlogging.LogErrorf(\"publish export .sy.zip [%s] failed: %s\", zipPath, err)\n\t\treturn \"\"\n\t}\n\n\tos.RemoveAll(exportDir)\n\tif encrypted {\n\t\tzipPath = \"/export/\" + registerManagedEncryptedExport(boxID, \"sy\", zipPath)\n\t} else {\n\t\tzipPath = \"/export/\" + url.PathEscape(filepath.Base(zipPath))\n\t}\n\treturn\n}\n\nfunc attributeViewExportError(avID string, err error) error {\n\treturn fmt.Errorf(\"%s: %w\", fmt.Sprintf(Conf.Language(382), avID), err)\n}\n\nfunc exportAv(avID, boxID, exportStorageAvDir, exportFolder string, assetPathMap map[string]string) error {\n\t// 用 box-aware 路径解析 + 自动解密读取 AV 定义明文（加密笔记本的 AV 在 <boxID>/storage/av/，\n\t// GetAttributeViewDataPath 只查全局路径会漏；filelock.Copy 会拷密文）。\n\tavData, readErr := av.ReadAttributeViewDataInBox(avID, boxID)\n\tif readErr != nil {\n\t\tlogging.LogErrorf(\"read attribute view [%s] failed: %s\", avID, readErr)\n\t\treturn attributeViewExportError(avID, readErr)\n\t}\n\tif boxID != \"\" && avData != nil {\n\t\tavData, readErr = rewriteAttributeViewDataAssetReferences(avData, assetReferenceRewriteOptions{rewriteUnmapped: true})\n\t\tif readErr != nil {\n\t\t\tlogging.LogErrorf(\"rewrite exported attribute view assets [%s] failed: %s\", avID, readErr)\n\t\t\treturn readErr\n\t\t}\n\t}\n\tif avData != nil {","sourceCodeStart":2960,"sourceCodeEnd":2996,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/export.go#L2960-L2996","documentation":"attributeViewExportError wraps any failure while exporting an attribute view (database) as '<Cannot export database [%s]>: <cause>' using i18n message 382 with the avID. It gives the user a localized message while preserving the underlying cause via %w for programmatic inspection.","triggerScenarios":"exportAv fails at any stage — reading AV data (av.ReadAttributeViewDataInBox), decrypting an encrypted box's AV definition, copying AV storage files, or writing exported files — and the error is wrapped via attributeViewExportError(avID, err).","commonSituations":"Document references a database whose .av file is missing or corrupt; exporting from an encrypted notebook where the AV definition cannot be decrypted; storage/av files locked or unreadable.","solutions":["Inspect the wrapped cause (%w / errors.Unwrap) for the real failure — missing file, decrypt failure, or copy error","Verify the database binding in the document and that <box>/storage/av/<avID>.av exists and is valid","For encrypted notebooks, ensure the box data is intact and accessible (correct keys/data present)"],"exampleFix":"// before\nreturn attributeViewExportError(avID, err) // opaque\n// after\ncallers can do:\nif unwrapped := errors.Unwrap(err); unwrapped != nil { log(unwrapped) }","handlingStrategy":"try-catch","validationCode":"const avPath = path.join(boxID, 'storage', 'av', avID + '.av');\nif (!fs.existsSync(path.join(workspaceDir, avPath))) {\n  notify('Database definition missing: ' + avPath);\n}","typeGuard":null,"tryCatchPattern":"try { await exportDoc(id); }\ncatch (e) {\n  if (/Cannot export database \\[.+\\]/.test(String(e))) {\n    const cause = e.cause || String(e);\n    log('AV export failed:', cause); // unwrapped root cause\n    fixDatabaseBindingOrDecrypt(cause);\n  }\n}","preventionTips":["Verify each database binding in the document points to an existing storage/av/<avID>.av","Keep encrypted notebook data intact and keys available before exporting","Avoid editing or moving .av files outside the SiYuan data directory"],"tags":["export","attribute-view","database"],"backgroundTag":"database-query-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"}