{"record":{"id":"c5bd3b3aeb888950","repo":"siyuan-note/siyuan","slug":"26","errorCode":"26","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/251596fc0de2f9528c00c224252fd073a99973f4/kernel/model/history_diff.go#L384-L420","documentation":"Returned by loadSnapshotDocVersion (history_diff.go:402) as Conf.Language(26) = \"Please initialize the data repo key first in [Settings - Account & Sync - Local Data Repo - Data repo key]\". Snapshots are stored in the dejavu data repo which is encrypted with Conf.Repo.Key; if that key is uninitialized (len < 1), no repo object can be opened. The guard fires before newRepository so the user gets a setup hint instead of a repo-open error.","triggerScenarios":"Any call to loadSnapshotDocVersion on a workspace where the data repo key has never been created; a fresh install where the user opened the diff dialog against a snapshot before completing first-time setup; a corrupted conf that lost the key.","commonSituations":"New workspace that has not gone through Settings - Account & Sync - Local Data Repo - Data repo key initialization; migration between machines without copying the key; a config reset.","solutions":["Initialize the data repo key at Settings - Account & Sync - Local Data Repo - Data repo key (Create/Import), then retry.","If the key was created but lost, restore it from the user's backup; otherwise snapshots from the old key are unrecoverable.","At the API layer, surface code 26 verbatim so the client can deep-link to the repo-key settings panel."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if 1 > len(Conf.Repo.Key) {\n    return errors.New(Conf.Language(26))\n}\n// safe to load snapshot doc version","typeGuard":null,"tryCatchPattern":"diff, err := DiffDocVersions(left, right)\nif err != nil && err.Error() == Conf.Language(26) {\n    // route user to Settings - Account & Sync - Local Data Repo - Data repo key\n}","preventionTips":["Initialize the data repo key during first-time workspace setup.","Back up the repo key alongside the workspace so it can be restored after migration.","Surface code 26 verbatim so the client can deep-link to the repo-key settings."],"tags":["configuration","data-repo","snapshot","encryption","setup"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}