siyuan-note/siyuan · error
history path [ ] not exist
Error message
history path [%s] not exist
What it means
After confirming the path is inside the workspace, validateHistoryPath checks existence on disk. This error means the normalized history path does not point to an existing file or directory — the history entry was pruned, never created, or the path is mistyped.
Solutions
- Re-list available history entries via the history APIs and use a fresh, currently existing path
- Check the history retention settings — increase RetentionDays if snapshots are pruned too aggressively
- Verify the workspace directory is the one that actually contains the history data
Example fix
// before rollbackDocHistory(staleHistoryPath) // snapshot already pruned // after histories := getHistoryItems(); rollbackDocHistory(histories[0].path) // re-fetched live path
Defensive patterns
Strategy: validation
Validate before calling
if (!fs.existsSync(path.join(workspaceDir, historyPath))) { const fresh = await fetchLatestHistoryEntries(); historyPath = fresh[0].path; } Try / catch
try { await rollbackDocHistory(p); } catch (e) { if (String(e).includes('not exist')) { await refreshHistoryList(); informUserSnapshotPruned(); } else { throw e; } } Prevention
- Re-fetch history listings instead of caching paths across sessions
- Increase history retention (RetentionDays) for snapshots you plan to restore later
- Check that the workspace directory matches the one containing the data
When it happens
Trigger: Calling any history read/rollback API with a path under the workspace whose joined absolute path does not exist — typically after history auto-cleanup deleted the snapshot or the caller reused a stale path from a previous session.
Common situations: Cached history paths used after the retention window elapsed and the kernel purged old history; workspaces switched between calls; typos in the timestamp or op segment.
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
- attribute view history context is ambiguous
- attribute view not found
- attribute view snapshot context is ambiguous
- can not get or create rollback box
- cannot allocate a replacement history directory
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/57421fc21b3d3113.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/model/history.go:609
if err = filelock.CopyNewtimes(from, to); err != nil {
logging.LogErrorf("copy file [%s] to [%s] failed: %s", from, to, err)
return
}
IncSync()
util.PushMsg(Conf.Language(102), 3000)
return nil
}
// validateHistoryPath 校验历史路径是否位于工作区内且属于历史目录。
// 拒绝路径穿越攻击(..、绝对路径等)。返回规范化的绝对路径。
func validateHistoryPath(historyPath string) (string, error) {
p := filepath.Join(util.WorkspaceDir, historyPath)
if !gulu.File.IsSubPath(util.WorkspaceDir, p) {
return "", fmt.Errorf("history path [%s] is not in workspace", historyPath)
}
if !gulu.File.IsExist(p) {
return "", fmt.Errorf("history path [%s] not exist", historyPath)
}
rel, err := filepath.Rel(util.HistoryDir, p)
if err != nil || strings.HasPrefix(rel, "..") {
return "", fmt.Errorf("history path [%s] is not under history directory", historyPath)
}
return p, nil
}
// IsEncryptedHistoryPath 判断历史路径是否明确属于加密笔记本。
func IsEncryptedHistoryPath(absPath string) bool {
boxID := ExtractBoxIDFromHistoryPath(absPath)
if boxID == "" {
return false
}
if IsEncryptedBox(boxID) {
return true
}
rel, err := filepath.Rel(util.HistoryDir, absPath)View on GitHub (pinned to 9f775e8a12)