siyuan-note/siyuan · error
encrypted attribute view history is missing valid notebook…
Error message
encrypted attribute view history is missing valid notebook context
What it means
When the history AV snapshot file reads back as ciphertext (encrypted notebook data), the path must still identify an encrypted notebook: the path must have enough segments, segment 1 must be a node-ID-shaped box ID, and that box must be an encrypted notebook. If any of these fail, the kernel cannot determine where/how to decrypt and restore the snapshot, so it aborts with this error. This protects encrypted-notebook recovery paths from ambiguous or corrupted history paths.
Solutions
- Restore the original directory layout history/<timestamp>/storage/av/... including the notebook ID segment.
- Confirm the notebook ID in the path is an existing encrypted notebook (IsEncryptedBox true).
- If the file is actually plaintext, ensure it is stored as plaintext; if it is ciphertext, re-create the snapshot from the encrypted notebook.
Defensive patterns
Strategy: validation
Validate before calling
const parts = relPath.split("/");
if (isCiphertext(data) && (parts.length < 3 || !/^[0-9]{14}-[a-z0-9]{7}$/.test(parts[1]) || !isEncryptedBox(parts[1]))) {
throw new Error("ciphertext AV history lacks valid notebook context");
} Type guard
function hasValidBoxContext(relPath, isEncryptedBox) {
const parts = relPath.split("/");
return parts.length >= 3 && isEncryptedBox(parts[1]);
} Prevention
- Never move or copy files out of the history/<stamp>/ storage/av/ layout.
- Keep the notebook ID segment intact when migrating history data.
- Re-derive paths from the history index after any restore.
When it happens
Trigger: RollbackAttributeViewHistory called with a ciphertext AV history file whose path has fewer than 3 segments after trimming the history dir, whose second segment is not a valid node ID, or whose second segment is not a recognized encrypted notebook ID.
Common situations: History files copied/moved out of their per-notebook directory; manually restructured history folders; encrypted notebook removed or its encryption status changed after the snapshot was taken; path built by hand without the box ID segment.
Understand the failure class
Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.
Related errors
- invalid AV history path
- Argon2id KeyLength must be 32
- Argon2id Memory too low (minimum 64 MB)
- asset path must be under assets
- at least one visible view is required
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/1faee020d3ad5137.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/model/history.go:708
return
}
// 验证目标文件必须是 AV 定义文件
if !strings.HasSuffix(historyPath, ".json") || !strings.Contains(filepath.ToSlash(historyPath), "/storage/av/") {
return fmt.Errorf("invalid AV history path [%s]", historyPath)
}
from := historyPath
// 从路径提取 boxID 判断是否加密笔记本的 AV
relPath := strings.TrimPrefix(filepath.ToSlash(historyPath), filepath.ToSlash(util.HistoryDir))
relPath = strings.TrimPrefix(relPath, "/")
pathParts := strings.SplitN(relPath, "/", 3)
data, readErr := filelock.ReadFile(from)
if readErr != nil {
return readErr
}
ciphertext := util.IsCiphertext(data)
if ciphertext && (len(pathParts) < 3 || !ast.IsNodeIDPattern(pathParts[1]) || !IsEncryptedBox(pathParts[1])) {
return errors.New("encrypted attribute view history is missing valid notebook context")
}
to := filepath.Join(util.DataDir, "storage", "av", filepath.Base(historyPath))
if len(pathParts) >= 2 && IsEncryptedBox(pathParts[1]) {
if !ciphertext {
return fmt.Errorf("encrypted notebook attribute view history is plaintext [%s]", pathParts[1])
}
// 加密笔记本的 AV 定义回滚到笔记本级目录
to = filepath.Join(util.DataDir, pathParts[1], "storage", "av", filepath.Base(historyPath))
if err = os.MkdirAll(filepath.Dir(to), 0755); err != nil {
return
}
}
if err = filelock.CopyNewtimes(from, to); err != nil {
logging.LogErrorf("copy file [%s] to [%s] failed: %s", from, to, err)
return
}
avID := strings.TrimSuffix(filepath.Base(historyPath), ".json")View on GitHub (pinned to 9f775e8a12)