siyuan-note/siyuan · error
: (Conf.Language(382) with avID)
Error message
%s: %w (Conf.Language(382) with avID)
What it means
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.
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)
Example fix
// before
return attributeViewExportError(avID, err) // opaque
// after
callers can do:
if unwrapped := errors.Unwrap(err); unwrapped != nil { log(unwrapped) } Defensive patterns
Strategy: try-catch
Validate before calling
const avPath = path.join(boxID, 'storage', 'av', avID + '.av');
if (!fs.existsSync(path.join(workspaceDir, avPath))) {
notify('Database definition missing: ' + avPath);
} Try / catch
try { await exportDoc(id); }
catch (e) {
if (/Cannot export database \[.+\]/.test(String(e))) {
const cause = e.cause || String(e);
log('AV export failed:', cause); // unwrapped root cause
fixDatabaseBindingOrDecrypt(cause);
}
} Prevention
- 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
When it happens
Trigger: 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).
Common situations: 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.
Understand the failure class
Background: Database query failed: Internal Server Error 500s wrapping SQL, Prisma, and connection failures — what to check first — this error's family across 16 libraries.
Related errors
- attribute view not found
- cannot remove primary key field
- clone attribute view value
- current document is not bound to the context filter target…
- database back relation changed since document deletion
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/809378207c98fafc.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/model/export.go:2978
logging.LogErrorf("close export .sy.zip failed: %s", err)
return ""
}
if err = os.Rename(zipPartialPath, zipPath); err != nil {
logging.LogErrorf("publish export .sy.zip [%s] failed: %s", zipPath, err)
return ""
}
os.RemoveAll(exportDir)
if encrypted {
zipPath = "/export/" + registerManagedEncryptedExport(boxID, "sy", zipPath)
} else {
zipPath = "/export/" + url.PathEscape(filepath.Base(zipPath))
}
return
}
func attributeViewExportError(avID string, err error) error {
return fmt.Errorf("%s: %w", fmt.Sprintf(Conf.Language(382), avID), err)
}
func exportAv(avID, boxID, exportStorageAvDir, exportFolder string, assetPathMap map[string]string) error {
// 用 box-aware 路径解析 + 自动解密读取 AV 定义明文(加密笔记本的 AV 在 <boxID>/storage/av/,
// GetAttributeViewDataPath 只查全局路径会漏;filelock.Copy 会拷密文)。
avData, readErr := av.ReadAttributeViewDataInBox(avID, boxID)
if readErr != nil {
logging.LogErrorf("read attribute view [%s] failed: %s", avID, readErr)
return attributeViewExportError(avID, readErr)
}
if boxID != "" && avData != nil {
avData, readErr = rewriteAttributeViewDataAssetReferences(avData, assetReferenceRewriteOptions{rewriteUnmapped: true})
if readErr != nil {
logging.LogErrorf("rewrite exported attribute view assets [%s] failed: %s", avID, readErr)
return readErr
}
}
if avData != nil {View on GitHub (pinned to 9f775e8a12)