{"record":{"id":"a124cc6221e46941","repo":"siyuan-note/siyuan","slug":"conf-language-26-a124cc","errorCode":null,"errorMessage":"Conf.Language(26)","messagePattern":"Conf\\.Language\\(26\\)","errorType":"exception","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/9f775e8a12daef8255556097396f9b2739078892/kernel/model/history_diff.go#L384-L420","documentation":"Snapshot files in the encrypted repo store are encrypted at rest, so opening one requires the repository key. loadSnapshotDocVersion checks Conf.Repo.Key before constructing the repository; when no repo key is configured, it returns the localized message 26 (the 'repo key is required / passphrase needed' prompt) instead of attempting repo access.","triggerScenarios":"loadDocVersion in snapshot mode with a valid fileID while the workspace has no repository key set (Conf.Repo.Key empty) — i.e. cloud/snapshot sync was never initialized with a passphrase, or the key was cleared.","commonSituations":"Fresh workspace restore where the repo key was not re-entered; user cleared or reset the sync passphrase; opening snapshots before setting up cloud sync; Conf.Repo.Key lost after config corruption.","solutions":["Set up / re-enter the repository passphrase via the sync settings so Conf.Repo.Key is populated, then retry.","If the repo key was lost, the snapshot content is unrecoverable from this workspace — restore from a source that knows the passphrase.","Programmatically check len(Conf.Repo.Key) > 0 (or the repo-init state API) before requesting snapshot versions.","Verify the correct workspace is open; a different workspace may have no initialized repo."],"exampleFix":"// before: snapshot diff without repo key\nloadDocVersion(snapshotFileID) -> Conf.Language(26)\n// after: initialize repo first\nPOST /api/repo/initRepoKey { \"password\": \"...\" }\nloadDocVersion(snapshotFileID)","handlingStrategy":"validation","validationCode":"// Go: confirm a repo key exists before snapshot version access\nif 1 > len(Conf.Repo.Key) {\n    return errors.New(\"repository key not configured; initialize repo key first\")\n}","typeGuard":null,"tryCatchPattern":"catch (e) { if (e.msg.includes(Langs[26])) { openRepoKeySetupDialog(); } else { throw e; } }","preventionTips":["Initialize the repository key (sync passphrase) before using snapshot features","After workspace restore, re-enter the repo key immediately","Verify the intended workspace with an initialized repo is open"],"tags":["repo","encryption","missing-key","snapshot"],"backgroundTag":"missing-api-key","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}