{"record":{"id":"1cc1faf03c7799c1","repo":"siyuan-note/siyuan","slug":"please-initialize-the-data-repo-key-first-in-sett","errorCode":null,"errorMessage":"Please initialize the data repo key first in [Settings - Account & Sync - Local Data Repo - Data repo key]","messagePattern":"Please initialize the data repo key first in \\[Settings - Account & Sync - Local Data Repo - Data repo key\\]","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/history_diff.go","lineNumber":402,"sourceCode":"\t\t}, nil\n\t}\n\treturn &loadedDocVersion{\n\t\ttree:    tree,\n\t\ttitle:   tree.Root.IALAttr(\"title\"),\n\t\trootID:  tree.Root.ID,\n\t\traw:     data,\n\t\tlarge:   1024*1024 <= len(data),\n\t\tboxID:   boxID,\n\t\thistory: historyRoot,\n\t}, nil\n}\n\nfunc loadSnapshotDocVersion(fileID string) (ret *loadedDocVersion, err error) {\n\tif \"\" == fileID {\n\t\treturn nil, errors.New(\"snapshot file ID is required\")\n\t}\n\tif 1 > len(Conf.Repo.Key) {\n\t\treturn nil, errors.New(Conf.Language(26))\n\t}\n\trepo, err := newRepository()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tfile, err := repo.GetFile(fileID)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif !strings.HasSuffix(strings.ToLower(file.Path), \".sy\") {\n\t\treturn nil, errors.New(\"snapshot version is not a document\")\n\t}\n\trepoPath := strings.TrimPrefix(file.Path, \"/\")\n\tpathParts := strings.SplitN(repoPath, \"/\", 2)\n\tdata, err := repo.OpenFile(file)\n\tif err != nil {\n\t\treturn nil, err\n\t}","sourceCodeStart":384,"sourceCodeEnd":420,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/afa823b6b4e4f183511e0bc0a3be93caa94c7c97/kernel/model/history_diff.go#L384-L420","documentation":"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.","triggerScenarios":"Any DiffDocVersions call where a ref has Type snapshot before the data repo key has been created or imported in this workspace.","commonSituations":"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.","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"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// kernel/plugin-side: check repo key before snapshot diffs\nif 1 > len(model.Conf.Repo.Key) {\n    return errors.New(\"data repo key is not initialized\")\n}\ndiff, err := model.DiffDocVersions(left, right)","typeGuard":null,"tryCatchPattern":"diff, err := model.DiffDocVersions(left, right)\nif err != nil {\n    if strings.Contains(err.Error(), \"data repo key\") {\n        // guide user to Settings - Account & Sync - Local Data Repo - Data repo key, then retry\n    }\n    return err\n}","preventionTips":["Import the repo key as part of workspace setup on new devices","Guard automated snapshot features behind a repo-key availability check"],"tags":["go","siyuan","snapshot","encryption-key","config"],"backgroundTag":"missing-encryption-key","analyzedSha":"afa823b6b4e4f183511e0bc0a3be93caa94c7c97","analyzedAt":"2026-08-18T17:04:10.865Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}