siyuan-note/siyuan · error
Please initialize the data repo key first in [Settings -…
Error message
Please initialize the data repo key first in [Settings - Account & Sync - Local Data Repo - Data repo key]
What it means
Snapshot versions are read from the local data repo (dejavu), which is end-to-end encrypted with a repo key. If Conf.Repo.Key is empty the repo cannot be opened, so the kernel returns the localized prompt to initialize the key under Settings - Account & Sync - Local Data Repo - Data repo key (Conf.Language(26)). This is a workspace-configuration precondition, not a per-call data problem.
Solutions
- Create or import the data repo key in Settings - Account & Sync - Local Data Repo - Data repo key, then retry
- If the workspace already had a key, import the previously exported key instead of creating a new one
- Avoid snapshot-type refs in flows that must work without a repo key
Defensive patterns
Strategy: validation
Validate before calling
// kernel/plugin-side: check repo key before snapshot diffs
if 1 > len(model.Conf.Repo.Key) {
return errors.New("data repo key is not initialized")
}
diff, err := model.DiffDocVersions(left, right) Try / catch
diff, err := model.DiffDocVersions(left, right)
if err != nil {
if strings.Contains(err.Error(), "data repo key") {
// guide user to Settings - Account & Sync - Local Data Repo - Data repo key, then retry
}
return err
} Prevention
- Import the repo key as part of workspace setup on new devices
- Guard automated snapshot features behind a repo-key availability check
When it happens
Trigger: Any DiffDocVersions call where a ref has Type snapshot before the data repo key has been created or imported in this workspace.
Common situations: Fresh workspace or new device without an imported repo key; config reset; switching workspaces; snapshots listed by the UI but the key was never set up.
Related errors
- attribute view spec is too new
- Conf.Language(26)
- Conf.Language(34)
- filter nesting depth exceeds the maximum allowed
- invalid agent permission mode
AI-assisted analysis of siyuan-note/siyuan@afa823b6b4 (2026-08-18).
Data as JSON: /api/errors/1cc1faf03c7799c1.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/model/history_diff.go:402
}, nil
}
return &loadedDocVersion{
tree: tree,
title: tree.Root.IALAttr("title"),
rootID: tree.Root.ID,
raw: data,
large: 1024*1024 <= len(data),
boxID: boxID,
history: historyRoot,
}, nil
}
func loadSnapshotDocVersion(fileID string) (ret *loadedDocVersion, err error) {
if "" == fileID {
return nil, errors.New("snapshot file ID is required")
}
if 1 > len(Conf.Repo.Key) {
return nil, errors.New(Conf.Language(26))
}
repo, err := newRepository()
if err != nil {
return nil, err
}
file, err := repo.GetFile(fileID)
if err != nil {
return nil, err
}
if !strings.HasSuffix(strings.ToLower(file.Path), ".sy") {
return nil, errors.New("snapshot version is not a document")
}
repoPath := strings.TrimPrefix(file.Path, "/")
pathParts := strings.SplitN(repoPath, "/", 2)
data, err := repo.OpenFile(file)
if err != nil {
return nil, err
}View on GitHub (pinned to afa823b6b4)